drivers/gpib/tnt4882/mite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
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@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
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
On Wed, Sep 16, 2026 at 09:45:58AM +0000, Wentao Liang wrote:
> 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@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> 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);
Acked-by: Dave Penkler <dpenkler@gmail.com>
thanks
> --
> 2.34.1
>
© 2016 - 2026 Red Hat, Inc.