mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Penkler <dpenkler@gmail.com>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] gpib: tnt4882: Fix device reference leak in mite_init()
Date: Fri, 18 Sep 2026 11:58:27 +0200	[thread overview]
Message-ID: <aq0LQw2mrEYJ-jNx@egonzo> (raw)
In-Reply-To: <20260916094558.2007240-1-vulab@iscas.ac.cn>

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
> 

      reply	other threads:[~2026-09-18  9:58 UTC|newest]

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

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=aq0LQw2mrEYJ-jNx@egonzo \
    --to=dpenkler@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vulab@iscas.ac.cn \
    /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®