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 <stable@kernel.org>
Fixes: 8e4841a0888c ("staging: gpib: Add Frank Mori Hess FPGA PCI GPIB driver")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by Ma Ke and committed by Greg Kroah-Hartman b1aabb8e aaf2af1e

Changed files
+5
drivers
staging
gpib
fmh_gpib
+5
drivers/staging/gpib/fmh_gpib/fmh_gpib.c
··· 1517 1517 resource_size(e_priv->gpib_iomem_res)); 1518 1518 } 1519 1519 fmh_gpib_generic_detach(board); 1520 + 1521 + if (board->dev) { 1522 + put_device(board->dev); 1523 + board->dev = NULL; 1524 + } 1520 1525 } 1521 1526 1522 1527 static int fmh_gpib_pci_attach_impl(struct gpib_board *board,