diff options
author | Sjur Braendeland <sjur.brandeland@stericsson.com> | 2010-04-28 04:54:34 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-28 15:55:10 -0400 |
commit | d3f744e0d6c1c27a10cdceac6eb946122188dbc9 (patch) | |
tree | 29ea75a920eba781d617c4e1ef30298952a73d27 /drivers/net/caif | |
parent | a4900ac9f7d10ad062e54dd03125e3619e0ac17a (diff) |
caif: Ldisc add permission check and mem-alloc error check
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>
Diffstat (limited to 'drivers/net/caif')
-rw-r--r-- | drivers/net/caif/caif_serial.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index 38c0186cfbc2..09257ca8f563 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c | |||
@@ -197,7 +197,8 @@ static void ldisc_receive(struct tty_struct *tty, const u8 *data, | |||
197 | 197 | ||
198 | /* Get a suitable caif packet and copy in data. */ | 198 | /* Get a suitable caif packet and copy in data. */ |
199 | skb = netdev_alloc_skb(ser->dev, count+1); | 199 | skb = netdev_alloc_skb(ser->dev, count+1); |
200 | BUG_ON(skb == NULL); | 200 | if (skb == NULL) |
201 | return; | ||
201 | p = skb_put(skb, count); | 202 | p = skb_put(skb, count); |
202 | memcpy(p, data, count); | 203 | memcpy(p, data, count); |
203 | 204 | ||
@@ -315,6 +316,8 @@ static int ldisc_open(struct tty_struct *tty) | |||
315 | /* No write no play */ | 316 | /* No write no play */ |
316 | if (tty->ops->write == NULL) | 317 | if (tty->ops->write == NULL) |
317 | return -EOPNOTSUPP; | 318 | return -EOPNOTSUPP; |
319 | if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_TTY_CONFIG)) | ||
320 | return -EPERM; | ||
318 | 321 | ||
319 | sprintf(name, "cf%s", tty->name); | 322 | sprintf(name, "cf%s", tty->name); |
320 | dev = alloc_netdev(sizeof(*ser), name, caifdev_setup); | 323 | dev = alloc_netdev(sizeof(*ser), name, caifdev_setup); |