diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-09-01 22:19:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-09-16 17:40:34 -0400 |
commit | 4fb66b8210c7d7147b164e19b1b44da916a75691 (patch) | |
tree | 203f37890eb96313224c7bf431622297b1a0601d /net/caif/caif_dev.c | |
parent | d5ccd496601b8776a516d167a6485754575dc38f (diff) |
caif: fix a potential NULL dereference
Commit bd30ce4bc0b7 (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>
Diffstat (limited to 'net/caif/caif_dev.c')
-rw-r--r-- | net/caif/caif_dev.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c index 7c2fa0a08148..7f9ac0742d19 100644 --- a/net/caif/caif_dev.c +++ b/net/caif/caif_dev.c | |||
@@ -93,10 +93,14 @@ static struct caif_device_entry *caif_device_alloc(struct net_device *dev) | |||
93 | caifdevs = caif_device_list(dev_net(dev)); | 93 | caifdevs = caif_device_list(dev_net(dev)); |
94 | BUG_ON(!caifdevs); | 94 | BUG_ON(!caifdevs); |
95 | 95 | ||
96 | caifd = kzalloc(sizeof(*caifd), GFP_ATOMIC); | 96 | caifd = kzalloc(sizeof(*caifd), GFP_KERNEL); |
97 | if (!caifd) | 97 | if (!caifd) |
98 | return NULL; | 98 | return NULL; |
99 | caifd->pcpu_refcnt = alloc_percpu(int); | 99 | caifd->pcpu_refcnt = alloc_percpu(int); |
100 | if (!caifd->pcpu_refcnt) { | ||
101 | kfree(caifd); | ||
102 | return NULL; | ||
103 | } | ||
100 | caifd->netdev = dev; | 104 | caifd->netdev = dev; |
101 | dev_hold(dev); | 105 | dev_hold(dev); |
102 | return caifd; | 106 | return caifd; |