Skip to content

Commit

Permalink
caif: fix a potential NULL dereference
Browse files Browse the repository at this point in the history
Commit bd30ce4 (caif: Use RCU instead of spin-lock in caif_dev.c)
added a potential NULL dereference in case alloc_percpu() fails.

caif_device_alloc() can also use GFP_KERNEL instead of GFP_ATOMIC.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Sjur Brændeland <sjur.brandeland@stericsson.com>
Acked-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Sep 16, 2011
1 parent d5ccd49 commit 4fb66b8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/caif/caif_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ static struct caif_device_entry *caif_device_alloc(struct net_device *dev)
caifdevs = caif_device_list(dev_net(dev));
BUG_ON(!caifdevs);

caifd = kzalloc(sizeof(*caifd), GFP_ATOMIC);
caifd = kzalloc(sizeof(*caifd), GFP_KERNEL);
if (!caifd)
return NULL;
caifd->pcpu_refcnt = alloc_percpu(int);
if (!caifd->pcpu_refcnt) {
kfree(caifd);
return NULL;
}
caifd->netdev = dev;
dev_hold(dev);
return caifd;
Expand Down

0 comments on commit 4fb66b8

Please sign in to comment.