]> git.baikalelectronics.ru Git - kernel.git/commitdiff
usbnet: ipheth: fix potential null pointer dereference in ipheth_carrier_set
authorGustavo A. R. Silva <garsilva@embeddedor.com>
Fri, 17 Nov 2017 20:02:09 +0000 (14:02 -0600)
committerDavid S. Miller <davem@davemloft.net>
Sun, 19 Nov 2017 03:23:57 +0000 (12:23 +0900)
_dev_ is being dereferenced before it is null checked, hence there
is a potential null pointer dereference.

Fix this by moving the pointer dereference after _dev_ has been null
checked.

Addresses-Coverity-ID: 1462020
Fixes: 07358bde2582 ("usbnet: ipheth: prevent TX queue timeouts when device not ready")
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/ipheth.c

index ca71f6c0385928a977c70096bbac49ca953b5d2d..7275761a1177ca9cda569bfc734bb6de3e1558e1 100644 (file)
@@ -291,12 +291,15 @@ static void ipheth_sndbulk_callback(struct urb *urb)
 
 static int ipheth_carrier_set(struct ipheth_device *dev)
 {
-       struct usb_device *udev = dev->udev;
+       struct usb_device *udev;
        int retval;
+
        if (!dev)
                return 0;
        if (!dev->confirmed_pairing)
                return 0;
+
+       udev = dev->udev;
        retval = usb_control_msg(udev,
                        usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP),
                        IPHETH_CMD_CARRIER_CHECK, /* request */