summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMa Ke <make24@iscas.ac.cn>2025-09-23 09:36:03 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-13 10:55:03 +0200
commitb1aabb8ef09b4cf0cc0c92ca9dfd19482f3192c1 (patch)
treec0e6b436b90ff4a8ed2db9d30ddbfe9cf67ef852
parentaaf2af1ed147ef49be65afb541a67255e9f60d15 (diff)
downloadlinux-b1aabb8ef09b4cf0cc0c92ca9dfd19482f3192c1.tar.gz
linux-b1aabb8ef09b4cf0cc0c92ca9dfd19482f3192c1.tar.bz2
linux-b1aabb8ef09b4cf0cc0c92ca9dfd19482f3192c1.zip
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>
-rw-r--r--drivers/staging/gpib/fmh_gpib/fmh_gpib.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/staging/gpib/fmh_gpib/fmh_gpib.c b/drivers/staging/gpib/fmh_gpib/fmh_gpib.c
index 164dcfc3c9ef..f7bfb4a8e553 100644
--- a/drivers/staging/gpib/fmh_gpib/fmh_gpib.c
+++ b/drivers/staging/gpib/fmh_gpib/fmh_gpib.c
@@ -1517,6 +1517,11 @@ void fmh_gpib_detach(struct gpib_board *board)
resource_size(e_priv->gpib_iomem_res));
}
fmh_gpib_generic_detach(board);
+
+ if (board->dev) {
+ put_device(board->dev);
+ board->dev = NULL;
+ }
}
static int fmh_gpib_pci_attach_impl(struct gpib_board *board,