]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
staging: rtl8192u: return -ENOMEM on failed allocation of priv->oldaddr
authorColin Ian King <colin.king@canonical.com>
Wed, 28 Feb 2018 11:28:49 +0000 (11:28 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Mar 2018 16:26:13 +0000 (17:26 +0100)
Currently the allocation of priv->oldaddr is not null checked which will
lead to subsequent errors when accessing priv->oldaddr.  Fix this with
a null pointer check and a return of -ENOMEM on allocation failure.

Detected with Coccinelle:
drivers/staging/rtl8192u/r8192U_core.c:1708:2-15: alloc with no test,
possible model on line 1723

Fixes: 8fc8598e61f6 ("Staging: Added Realtek rtl8192u driver to staging")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192u/r8192U_core.c

index 3c300f7b6a622c1c35b2e59be03956d5d052aa35..d607c59761cf29a02a31eee6f3026762b63f6599 100644 (file)
@@ -1706,6 +1706,8 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
 
                priv->rx_urb[16] = usb_alloc_urb(0, GFP_KERNEL);
                priv->oldaddr = kmalloc(16, GFP_KERNEL);
+               if (!priv->oldaddr)
+                       return -ENOMEM;
                oldaddr = priv->oldaddr;
                align = ((long)oldaddr) & 3;
                if (align) {