From: Guangshuo Li <lgs201920130244@gmail.com>
To: "Dave Penkler" <dpenkler@gmail.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Dominik Karol Piątkowski"
<dominik.karol.piatkowski@protonmail.com>,
"Uwe Kleine-König (The Capable Hub)"
<u.kleine-koenig@baylibre.com>,
"Guangshuo Li" <lgs201920130244@gmail.com>,
"Kees Cook" <kees@kernel.org>,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH] gpib: tnt4882: fix memory leak on probe failure
Date: Sun, 13 Sep 2026 14:36:03 +0800 [thread overview]
Message-ID: <20260913063603.1443403-1-lgs201920130244@gmail.com> (raw)
ni_gpib_probe() allocates a local_info_t structure and stores it in
link->priv before calling ni_gpib_config().
If ni_gpib_config() fails, it calls ni_gpib_release(), which only
disables the PCMCIA device and does not free the local_info_t
structure. Since probe then returns an error, the remove callback is
not called and the allocation is leaked.
Handle the configuration failure in ni_gpib_probe() by freeing the
local_info_t structure and clearing link->priv before returning the
error.
This issue was found by manual code inspection.
Fixes: 0cd5b05551e02 ("staging: gpib: Add TNT4882 chip based GPIB driver")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/gpib/tnt4882/tnt4882_gpib.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpib/tnt4882/tnt4882_gpib.c b/drivers/gpib/tnt4882/tnt4882_gpib.c
index 3cd13f637ed4..fc201ad17e30 100644
--- a/drivers/gpib/tnt4882/tnt4882_gpib.c
+++ b/drivers/gpib/tnt4882/tnt4882_gpib.c
@@ -1585,7 +1585,13 @@ static int ni_gpib_probe(struct pcmcia_device *link)
/* Register with Card Services */
curr_dev = link;
- return ni_gpib_config(link);
+ ret = ni_gpib_config(link);
+ if (ret) {
+ kfree(info);
+ link->priv = NULL;
+ }
+
+ return ret;
}
/*
--
2.43.0
next reply other threads:[~2026-09-13 6:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-13 6:36 Guangshuo Li [this message]
2026-09-13 21:22 ` kernel test robot
2026-09-13 22:16 ` kernel test robot
2026-09-14 6:06 ` kernel test robot
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=20260913063603.1443403-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=dominik.karol.piatkowski@protonmail.com \
--cc=dpenkler@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.com \
/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®