[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20170922193553.16358-1-christophe.jaillet@wanadoo.fr>
Date: Fri, 22 Sep 2017 21:35:53 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: gregkh@...uxfoundation.org, singhalsimran0@...il.com,
baoyou.xie@...aro.org, davem@...emloft.net, jarod@...hat.com,
szekelyszilv@...il.com, elia.f.geretto@...il.com,
gs051095@...il.com, shreeya.patel23498@...il.com,
robsonde@...il.com, colin.king@...onical.com
Cc: devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>
Subject: [PATCH] staging: rtl8192u: Check some memory allocation failure
If one of these memory allocations fail, a NULL pointer dereference will
occur later on.
Return -ENOMEM instead.
There is no need to free the resources already allocated, this is done
by the caller (i.e. 'rtl8192_usb_probe()') which calls
'rtl8192_usb_deleteendpoints()'.
The calling graph is:
rtl8192_usb_probe
--> rtl8192_init
--> rtl8192_usb_initendpoints
Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
The error handling path in 'rtl8192_usb_probe' must also be fixed because
it is bogus. Will do that in another patch.
---
drivers/staging/rtl8192u/r8192U_core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 46b3f19e0878..48b7fd071900 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -1687,9 +1687,13 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
#ifndef JACKSON_NEW_RX
for (i = 0; i < (MAX_RX_URB + 1); i++) {
priv->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
+ if (!priv->rx_urb[i])
+ return -ENOMEM;
priv->rx_urb[i]->transfer_buffer =
kmalloc(RX_URB_SIZE, GFP_KERNEL);
+ if (!priv->rx_urb[i]->transfer_buffer)
+ return -ENOMEM;
priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE;
}
--
2.11.0
Powered by blists - more mailing lists