mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wentao Liang <vulab@iscas.ac.cn>
To: dpenkler@gmail.com
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	Wentao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
Subject: [PATCH] gpib: tnt4882: Fix device reference leak in mite_init()
Date: Wed, 16 Sep 2026 09:45:58 +0000	[thread overview]
Message-ID: <20260916094558.2007240-1-vulab@iscas.ac.cn> (raw)

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


             reply	other threads:[~2026-09-16  9:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16  9:45 Wentao Liang [this message]
2026-09-18  9:58 ` Dave Penkler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260916094558.2007240-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=dpenkler@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®