Skip to content

Commit b1aabb8

Browse files
Ma Kegregkh
authored andcommitted
staging: gpib: Fix device reference leak in fmh_gpib driver
The fmh_gpib driver contains a device reference count leak in fmh_gpib_attach_impl() where driver_find_device() increases the reference count of the device by get_device() when matching but this reference is not properly decreased. Add put_device() in fmh_gpib_detach(), which ensures that the reference count of the device is correctly managed. Found by code review. Cc: stable <[email protected]> Fixes: 8e4841a ("staging: gpib: Add Frank Mori Hess FPGA PCI GPIB driver") Signed-off-by: Ma Ke <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent aaf2af1 commit b1aabb8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/staging/gpib/fmh_gpib/fmh_gpib.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,11 @@ void fmh_gpib_detach(struct gpib_board *board)
15171517
resource_size(e_priv->gpib_iomem_res));
15181518
}
15191519
fmh_gpib_generic_detach(board);
1520+
1521+
if (board->dev) {
1522+
put_device(board->dev);
1523+
board->dev = NULL;
1524+
}
15201525
}
15211526

15221527
static int fmh_gpib_pci_attach_impl(struct gpib_board *board,

0 commit comments

Comments
 (0)