* [PATCH] gpib: tnt4882: Fix device reference leak in mite_init()
@ 2026-09-16 9:45 Wentao Liang
2026-09-18 9:58 ` Dave Penkler
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-16 9:45 UTC (permalink / raw)
To: dpenkler; +Cc: gregkh, linux-kernel, Wentao Liang, stable
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
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] gpib: tnt4882: Fix device reference leak in mite_init()
2026-09-16 9:45 [PATCH] gpib: tnt4882: Fix device reference leak in mite_init() Wentao Liang
@ 2026-09-18 9:58 ` Dave Penkler
0 siblings, 0 replies; 2+ messages in thread
From: Dave Penkler @ 2026-09-18 9:58 UTC (permalink / raw)
To: Wentao Liang; +Cc: gregkh, linux-kernel, stable
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-18 9:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 9:45 [PATCH] gpib: tnt4882: Fix device reference leak in mite_init() Wentao Liang
2026-09-18 9:58 ` Dave Penkler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®