net: orinoco: add error handling for failed kmalloc().

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>
This commit is contained in:
Santosh Nayak 2012-03-22 12:42:41 +05:30 committed by John W. Linville
parent 75836b8dae
commit e90c7e7129

View File

@ -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;
@ -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);