]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
staging: rtl8192u: Check some memory allocation failure
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 22 Sep 2017 19:35:53 +0000 (21:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Oct 2017 16:34:57 +0000 (18:34 +0200)
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@wanadoo.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192u/r8192U_core.c

index 46b3f19e0878fa4741b189a76fa8987f599660c7..48b7fd071900fabe4413fa5a7ffdb20ef386fbfc 100644 (file)
@@ -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;
        }