Skip to content

Commit

Permalink
caif: Ldisc add permission check and mem-alloc error check
Browse files Browse the repository at this point in the history
Changes:
   o Added permission checks for installing. CAP_SYS_ADMIN and
     CAP_SYS_TTY_CONFIG can install the ldisc.
   o Check if allocation of skb was successful.

Signed-off-by: Sjur Braendeland <sjur.brandeland@stericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sjur Braendeland authored and David S. Miller committed Apr 28, 2010
1 parent a4900ac commit d3f744e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/caif/caif_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ static void ldisc_receive(struct tty_struct *tty, const u8 *data,

/* Get a suitable caif packet and copy in data. */
skb = netdev_alloc_skb(ser->dev, count+1);
BUG_ON(skb == NULL);
if (skb == NULL)
return;
p = skb_put(skb, count);
memcpy(p, data, count);

Expand Down Expand Up @@ -315,6 +316,8 @@ static int ldisc_open(struct tty_struct *tty)
/* No write no play */
if (tty->ops->write == NULL)
return -EOPNOTSUPP;
if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_TTY_CONFIG))
return -EPERM;

sprintf(name, "cf%s", tty->name);
dev = alloc_netdev(sizeof(*ser), name, caifdev_setup);
Expand Down

0 comments on commit d3f744e

Please sign in to comment.