rt2x00usb: Fix error return code
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>
Thu, 11 Aug 2016 14:38:54 +0000 (16:38 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Sat, 3 Sep 2016 10:06:49 +0000 (13:06 +0300)
We know that 'retval = 0' because it has been tested a few lines above.
So, if 'devm_kmalloc' fails, 0 will be returned instead of an error code.
Return -ENOMEM instead.

Fixes: 8b4c0009313f ("rt2x00usb: Use usb anchor to manage URB")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c

index 7cf26c6124d12e8246de910cab351ca902a945ea..6005e14213ca982c12cef1b1297c564b974aded0 100644 (file)
@@ -831,8 +831,10 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,
        rt2x00dev->anchor = devm_kmalloc(&usb_dev->dev,
                                        sizeof(struct usb_anchor),
                                        GFP_KERNEL);
-       if (!rt2x00dev->anchor)
+       if (!rt2x00dev->anchor) {
+               retval = -ENOMEM;
                goto exit_free_reg;
+       }
 
        init_usb_anchor(rt2x00dev->anchor);
        return 0;