From: Ma Ke Date: Tue, 23 Sep 2025 01:36:03 +0000 (+0800) Subject: staging: gpib: Fix device reference leak in fmh_gpib driver X-Git-Tag: v6.17.6~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fc48755c0f8e488284b764d902fa353e1325a5d3;p=thirdparty%2Fkernel%2Fstable.git staging: gpib: Fix device reference leak in fmh_gpib driver commit b1aabb8ef09b4cf0cc0c92ca9dfd19482f3192c1 upstream. 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 Fixes: 8e4841a0888c ("staging: gpib: Add Frank Mori Hess FPGA PCI GPIB driver") Signed-off-by: Ma Ke Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/gpib/fmh_gpib/fmh_gpib.c b/drivers/staging/gpib/fmh_gpib/fmh_gpib.c index 4138f3d2bae7f..efce01b39b9b1 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,