* [PATCH] gpio: sloppy-logic-analyzer: Fix memory leak in gpio_la_poll_probe()
@ 2026-07-10 6:48 Abdun Nihaal
2026-07-12 9:27 ` Wolfram Sang
2026-07-12 9:33 ` Wolfram Sang
0 siblings, 2 replies; 3+ messages in thread
From: Abdun Nihaal @ 2026-07-10 6:48 UTC (permalink / raw)
To: wsa+renesas; +Cc: Abdun Nihaal, linusw, brgl, linux-gpio, linux-kernel
The memory allocated for priv->blob.data is not freed in the error paths
that follow the fops_buf_size_set() call in gpio_la_poll_probe(), as
well as in the remove function. Fix that by using device managed action
to free the memory on remove.
Fixes: 7828b7bbbf20 ("gpio: add sloppy logic analyzer using polling")
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
---
Compile tested only. Issue found using static analysis.
drivers/gpio/gpio-sloppy-logic-analyzer.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-sloppy-logic-analyzer.c b/drivers/gpio/gpio-sloppy-logic-analyzer.c
index 2bbd308ca08e..7b4af98286e8 100644
--- a/drivers/gpio/gpio-sloppy-logic-analyzer.c
+++ b/drivers/gpio/gpio-sloppy-logic-analyzer.c
@@ -160,6 +160,13 @@ static int fops_buf_size_get(void *data, u64 *val)
return 0;
}
+static void fops_buf_release(void *data)
+{
+ struct gpio_la_poll_priv *priv = data;
+
+ vfree(priv->blob.data);
+}
+
static int fops_buf_size_set(void *data, u64 val)
{
struct gpio_la_poll_priv *priv = data;
@@ -237,7 +244,12 @@ static int gpio_la_poll_probe(struct platform_device *pdev)
if (ret)
return ret;
- fops_buf_size_set(priv, GPIO_LA_DEFAULT_BUF_SIZE);
+ ret = fops_buf_size_set(priv, GPIO_LA_DEFAULT_BUF_SIZE);
+ if (ret)
+ return ret;
+ ret = devm_add_action_or_reset(dev, fops_buf_release, priv);
+ if (ret)
+ return ret;
priv->descs = devm_gpiod_get_array(dev, "probe", GPIOD_IN);
if (IS_ERR(priv->descs))
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: sloppy-logic-analyzer: Fix memory leak in gpio_la_poll_probe()
2026-07-10 6:48 [PATCH] gpio: sloppy-logic-analyzer: Fix memory leak in gpio_la_poll_probe() Abdun Nihaal
@ 2026-07-12 9:27 ` Wolfram Sang
2026-07-12 9:33 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2026-07-12 9:27 UTC (permalink / raw)
To: Abdun Nihaal; +Cc: linusw, brgl, linux-gpio, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 337 bytes --]
On Fri, Jul 10, 2026 at 12:18:36PM +0530, Abdun Nihaal wrote:
> The memory allocated for priv->blob.data is not freed in the error paths
> that follow the fops_buf_size_set() call in gpio_la_poll_probe(), as
> well as in the remove function.
There is no memory allocated at that time. Hmm, maybe I should add a
comment explaining it.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: sloppy-logic-analyzer: Fix memory leak in gpio_la_poll_probe()
2026-07-10 6:48 [PATCH] gpio: sloppy-logic-analyzer: Fix memory leak in gpio_la_poll_probe() Abdun Nihaal
2026-07-12 9:27 ` Wolfram Sang
@ 2026-07-12 9:33 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2026-07-12 9:33 UTC (permalink / raw)
To: Abdun Nihaal; +Cc: linusw, brgl, linux-gpio, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 154 bytes --]
> Compile tested only. Issue found using static analysis.
Please update your analyzer to check if the original pointer is NULL.
Which one did you use?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-12 9:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-10 6:48 [PATCH] gpio: sloppy-logic-analyzer: Fix memory leak in gpio_la_poll_probe() Abdun Nihaal
2026-07-12 9:27 ` Wolfram Sang
2026-07-12 9:33 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox