linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8192u: Add null check in rtl8192_usb_initendpoints
@ 2020-12-26  8:02 Dinghao Liu
  2020-12-28 14:11 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Dinghao Liu @ 2020-12-26  8:02 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Greg Kroah-Hartman, Camylla Goncalves Cantanheide, Zhang Qilong,
	Colin Ian King, Masahiro Yamada, Michael Straube, Allen Pais,
	devel, linux-kernel

There is an allocation for priv->rx_urb[16] has no null check,
which may lead to a null pointer dereference.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/staging/rtl8192u/r8192U_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 93676af98629..9fc4adc83d77 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -1608,6 +1608,8 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
 		void *oldaddr, *newaddr;
 
 		priv->rx_urb[16] = usb_alloc_urb(0, GFP_KERNEL);
+		if (!priv->rx_urb[16])
+			return -ENOMEM;
 		priv->oldaddr = kmalloc(16, GFP_KERNEL);
 		if (!priv->oldaddr)
 			return -ENOMEM;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: rtl8192u: Add null check in rtl8192_usb_initendpoints
  2020-12-26  8:02 [PATCH] staging: rtl8192u: Add null check in rtl8192_usb_initendpoints Dinghao Liu
@ 2020-12-28 14:11 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2020-12-28 14:11 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: kjlu, devel, Camylla Goncalves Cantanheide, Zhang Qilong,
	linux-kernel, Colin Ian King, Allen Pais, Masahiro Yamada

On Sat, Dec 26, 2020 at 04:02:56PM +0800, Dinghao Liu wrote:
> There is an allocation for priv->rx_urb[16] has no null check,
> which may lead to a null pointer dereference.
> 
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index 93676af98629..9fc4adc83d77 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -1608,6 +1608,8 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
>  		void *oldaddr, *newaddr;
>  
>  		priv->rx_urb[16] = usb_alloc_urb(0, GFP_KERNEL);
> +		if (!priv->rx_urb[16])
> +			return -ENOMEM;
>  		priv->oldaddr = kmalloc(16, GFP_KERNEL);
>  		if (!priv->oldaddr)
>  			return -ENOMEM;

There is a bug here, where the memory is not freed from the alloc urb
call, right?

Anyway, something to fix up in a leter patch, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-28 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-26  8:02 [PATCH] staging: rtl8192u: Add null check in rtl8192_usb_initendpoints Dinghao Liu
2020-12-28 14:11 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).