]> Git Repo - linux.git/commitdiff
staging: gpib: Fix NULL pointer dereference in detach
authorDave Penkler <[email protected]>
Sat, 18 Jan 2025 14:50:45 +0000 (15:50 +0100)
committerGreg Kroah-Hartman <[email protected]>
Sun, 19 Jan 2025 08:06:30 +0000 (09:06 +0100)
When the detach function is called after a failed attach
the usb_dev initialization can cause a NULL pointer
dereference. This happens when the usb device is not found
in the attach procedure.

Remove the usb_dev variable and initialization and change the dev
in the dev_info message from the usb_dev to the gpib_dev.

Fixes: fbae7090f30c ("staging: gpib: Update messaging and usb_device refs in agilent_usb")
Signed-off-by: Dave Penkler <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
drivers/staging/gpib/agilent_82357a/agilent_82357a.c

index 34d85a1bdb37b6b16de0f1f35cc86cae43387947..2aaccebc3c7bdcb1b67bb0b062b12fee7a45eb8d 100644 (file)
@@ -1442,12 +1442,10 @@ static int agilent_82357a_go_idle(gpib_board_t *board)
 static void agilent_82357a_detach(gpib_board_t *board)
 {
        struct agilent_82357a_priv *a_priv;
-       struct usb_device *usb_dev;
 
        mutex_lock(&agilent_82357a_hotplug_lock);
 
        a_priv = board->private_data;
-       usb_dev = interface_to_usbdev(a_priv->bus_interface);
        if (a_priv) {
                if (a_priv->bus_interface) {
                        agilent_82357a_go_idle(board);
@@ -1459,7 +1457,7 @@ static void agilent_82357a_detach(gpib_board_t *board)
                agilent_82357a_cleanup_urbs(a_priv);
                agilent_82357a_free_private(a_priv);
        }
-       dev_info(&usb_dev->dev, "%s: detached\n", __func__);
+       dev_info(board->gpib_dev, "%s: detached\n", __func__);
        mutex_unlock(&agilent_82357a_hotplug_lock);
 }
 
This page took 0.056684 seconds and 4 git commands to generate.