Skip to content

Commit

Permalink
net: orinoco: add error handling for failed kmalloc().
Browse files Browse the repository at this point in the history
With flag 'GFP_ATOMIC', probability of allocation failure is more.
Add error handling after kmalloc() call to avoid null dereference.

Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Santosh Nayak authored and John W. Linville committed Mar 28, 2012
1 parent 75836b8 commit e90c7e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/net/wireless/orinoco/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,10 @@ static void qbuf_scan(struct orinoco_private *priv, void *buf,
unsigned long flags;

sd = kmalloc(sizeof(*sd), GFP_ATOMIC);
if (!sd) {
printk(KERN_ERR "%s: failed to alloc memory\n", __func__);
return;
}
sd->buf = buf;
sd->len = len;
sd->type = type;
Expand All @@ -1353,6 +1357,10 @@ static void qabort_scan(struct orinoco_private *priv)
unsigned long flags;

sd = kmalloc(sizeof(*sd), GFP_ATOMIC);
if (!sd) {
printk(KERN_ERR "%s: failed to alloc memory\n", __func__);
return;
}
sd->len = -1; /* Abort */

spin_lock_irqsave(&priv->scan_lock, flags);
Expand Down

0 comments on commit e90c7e7

Please sign in to comment.