Commit e90c7e71 authored by Santosh Nayak's avatar Santosh Nayak Committed by John W. Linville

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: default avatarSantosh Nayak <santoshprasadnayak@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 75836b8d
...@@ -1336,6 +1336,10 @@ static void qbuf_scan(struct orinoco_private *priv, void *buf, ...@@ -1336,6 +1336,10 @@ static void qbuf_scan(struct orinoco_private *priv, void *buf,
unsigned long flags; unsigned long flags;
sd = kmalloc(sizeof(*sd), GFP_ATOMIC); sd = kmalloc(sizeof(*sd), GFP_ATOMIC);
if (!sd) {
printk(KERN_ERR "%s: failed to alloc memory\n", __func__);
return;
}
sd->buf = buf; sd->buf = buf;
sd->len = len; sd->len = len;
sd->type = type; sd->type = type;
...@@ -1353,6 +1357,10 @@ static void qabort_scan(struct orinoco_private *priv) ...@@ -1353,6 +1357,10 @@ static void qabort_scan(struct orinoco_private *priv)
unsigned long flags; unsigned long flags;
sd = kmalloc(sizeof(*sd), GFP_ATOMIC); sd = kmalloc(sizeof(*sd), GFP_ATOMIC);
if (!sd) {
printk(KERN_ERR "%s: failed to alloc memory\n", __func__);
return;
}
sd->len = -1; /* Abort */ sd->len = -1; /* Abort */
spin_lock_irqsave(&priv->scan_lock, flags); spin_lock_irqsave(&priv->scan_lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment