All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: mux: demux-pinctrl: fix OF node leak on kstrdup failure
@ 2026-08-13  9:56 Linkai Gong
  2026-08-16 22:19 ` Andi Shyti
  0 siblings, 1 reply; 2+ messages in thread
From: Linkai Gong @ 2026-08-13  9:56 UTC (permalink / raw)
  To: Wolfram Sang, Peter Rosin
  Cc: Xiaoke Wang, linux-i2c, linux-kernel, Linkai Gong

of_parse_phandle() takes a reference on the parent node. If a later
devm_kstrdup() fails, err_rollback only releases nodes for indices
0..i-1, so the current node is leaked.

of_node_put() the current parent before rolling back.

Fixes: 7c0195fa9a9e ("i2c: mux: demux-pinctrl: check the return value of devm_kstrdup()")
Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>
---
 drivers/i2c/muxes/i2c-demux-pinctrl.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c
index f2a1f4744978..2403c0bf7c43 100644
--- a/drivers/i2c/muxes/i2c-demux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c
@@ -247,6 +247,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
 		props[i].value = devm_kstrdup(&pdev->dev, "ok", GFP_KERNEL);
 		if (!props[i].name || !props[i].value) {
 			err = -ENOMEM;
+			of_node_put(adap_np);
 			goto err_rollback;
 		}
 		props[i].length = 3;
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] i2c: mux: demux-pinctrl: fix OF node leak on kstrdup failure
  2026-08-13  9:56 [PATCH] i2c: mux: demux-pinctrl: fix OF node leak on kstrdup failure Linkai Gong
@ 2026-08-16 22:19 ` Andi Shyti
  0 siblings, 0 replies; 2+ messages in thread
From: Andi Shyti @ 2026-08-16 22:19 UTC (permalink / raw)
  To: Linkai Gong
  Cc: Wolfram Sang, Peter Rosin, Xiaoke Wang, linux-i2c, linux-kernel

Hi Linkai,

On Thu, Aug 13, 2026 at 05:56:17PM +0800, Linkai Gong wrote:
> of_parse_phandle() takes a reference on the parent node. If a later
> devm_kstrdup() fails, err_rollback only releases nodes for indices
> 0..i-1, so the current node is leaked.
> 
> of_node_put() the current parent before rolling back.
> 
> Fixes: 7c0195fa9a9e ("i2c: mux: demux-pinctrl: check the return value of devm_kstrdup()")
> Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>

merged to i2c/i2c-2.

Thanks,
Andi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-16 22:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13  9:56 [PATCH] i2c: mux: demux-pinctrl: fix OF node leak on kstrdup failure Linkai Gong
2026-08-16 22:19 ` Andi Shyti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.