[PATCH] gpib: tnt4882: Fix device reference leak in mite_init()

From: Wentao Liang

Date: Wed Sep 16 2026 - 05:53:21 EST


In mite_init(), each pci_get_device() iteration returns a new
reference to a National Instruments PCI device, which is consumed by
the next iteration. If kzalloc_obj() fails, the function returns
without consuming or putting that reference, leaking it.

Put the device reference before returning when the allocation fails.

Fixes: 0cd5b05551e0 ("staging: gpib: Add TNT4882 chip based GPIB driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/gpib/tnt4882/mite.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpib/tnt4882/mite.c b/drivers/gpib/tnt4882/mite.c
index c75c45cdf03f..3e411653ffc7 100644
--- a/drivers/gpib/tnt4882/mite.c
+++ b/drivers/gpib/tnt4882/mite.c
@@ -58,8 +58,10 @@ void mite_init(void)
pcidev;
pcidev = pci_get_device(PCI_VENDOR_ID_NATINST, PCI_ANY_ID, pcidev)) {
mite = kzalloc_obj(*mite);
- if (!mite)
+ if (!mite) {
+ pci_dev_put(pcidev);
return;
+ }

mite->pcidev = pcidev;
pci_dev_get(mite->pcidev);
--
2.34.1