Skip to content

Commit 6a6c153

Browse files
dpenklergregkh
authored andcommitted
staging: gpib: Fix NULL pointer dereference in detach
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: fbae709 ("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]>
1 parent 9ed145e commit 6a6c153

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/staging/gpib/agilent_82357a/agilent_82357a.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,12 +1442,10 @@ static int agilent_82357a_go_idle(gpib_board_t *board)
14421442
static void agilent_82357a_detach(gpib_board_t *board)
14431443
{
14441444
struct agilent_82357a_priv *a_priv;
1445-
struct usb_device *usb_dev;
14461445

14471446
mutex_lock(&agilent_82357a_hotplug_lock);
14481447

14491448
a_priv = board->private_data;
1450-
usb_dev = interface_to_usbdev(a_priv->bus_interface);
14511449
if (a_priv) {
14521450
if (a_priv->bus_interface) {
14531451
agilent_82357a_go_idle(board);
@@ -1459,7 +1457,7 @@ static void agilent_82357a_detach(gpib_board_t *board)
14591457
agilent_82357a_cleanup_urbs(a_priv);
14601458
agilent_82357a_free_private(a_priv);
14611459
}
1462-
dev_info(&usb_dev->dev, "%s: detached\n", __func__);
1460+
dev_info(board->gpib_dev, "%s: detached\n", __func__);
14631461
mutex_unlock(&agilent_82357a_hotplug_lock);
14641462
}
14651463

0 commit comments

Comments
 (0)