net: lan78xx: Bail out if lan78xx_get_endpoints fails
authorStefan Wahren <stefan.wahren@i2se.com>
Tue, 4 Sep 2018 17:29:09 +0000 (19:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Nov 2019 16:59:47 +0000 (17:59 +0100)
[ Upstream commit fa8cd98c06407b5798b927cd7fd14d30f360ed02 ]

We need to bail out if lan78xx_get_endpoints() fails, otherwise the
result is overwritten.

Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet")
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Raghuram Chary Jallipalli <raghuramchary.jallipalli@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/usb/lan78xx.c

index 78a12d7b96e86a624d0ba6243c35ba61744e89ab..2229284d16f56e08482bb399fbd6ec5a33682b1c 100644 (file)
@@ -2818,6 +2818,11 @@ static int lan78xx_bind(struct lan78xx_net *dev, struct usb_interface *intf)
        int i;
 
        ret = lan78xx_get_endpoints(dev, intf);
+       if (ret) {
+               netdev_warn(dev->net, "lan78xx_get_endpoints failed: %d\n",
+                           ret);
+               return ret;
+       }
 
        dev->data[0] = (unsigned long)kzalloc(sizeof(*pdata), GFP_KERNEL);