* [PATCH] soc: fsl: qe: Fix refcount leak in par_io_of_config
@ 2022-11-29 1:50 Zheng Yongjun
0 siblings, 0 replies; 2+ messages in thread
From: Zheng Yongjun @ 2022-11-29 1:50 UTC (permalink / raw)
To: qiang.zhao, leoyang.li, linuxppc-dev, linux-arm-kernel, linux-kernel
of_parse_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on error path.
Add missing of_node_put() to avoid refcount leak.
Fixes: 986585385131 ("[POWERPC] Add QUICC Engine (QE) infrastructure")
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
drivers/soc/fsl/qe/qe_io.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/soc/fsl/qe/qe_io.c b/drivers/soc/fsl/qe/qe_io.c
index a5e2d0e5ab51..e26836315167 100644
--- a/drivers/soc/fsl/qe/qe_io.c
+++ b/drivers/soc/fsl/qe/qe_io.c
@@ -159,11 +159,13 @@ int par_io_of_config(struct device_node *np)
pio_map = of_get_property(pio, "pio-map", &pio_map_len);
if (pio_map == NULL) {
printk(KERN_ERR "pio-map is not set!\n");
+ of_node_put(pio);
return -1;
}
pio_map_len /= sizeof(unsigned int);
if ((pio_map_len % 6) != 0) {
printk(KERN_ERR "pio-map format wrong!\n");
+ of_node_put(pio);
return -1;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] soc: fsl: qe: Fix refcount leak in par_io_of_config
@ 2022-04-03 12:19 Miaoqian Lin
0 siblings, 0 replies; 2+ messages in thread
From: Miaoqian Lin @ 2022-04-03 12:19 UTC (permalink / raw)
To: Qiang Zhao, Li Yang, Paul Mackerras, Shlomi Gridish,
Kim Phillips, linuxppc-dev, linux-arm-kernel, linux-kernel
Cc: linmq006
The device_node pointer is returned by of_parse_phandle() with
refcount incremented. We should use of_node_put() on it when done.
This function only calls of_node_put() in the regular path.
And it will cause refcount leak in error path.
Fixes: 986585385131 ("[POWERPC] Add QUICC Engine (QE) infrastructure")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/soc/fsl/qe/qe_io.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/soc/fsl/qe/qe_io.c b/drivers/soc/fsl/qe/qe_io.c
index a5e2d0e5ab51..9f5f746bea88 100644
--- a/drivers/soc/fsl/qe/qe_io.c
+++ b/drivers/soc/fsl/qe/qe_io.c
@@ -159,12 +159,12 @@ int par_io_of_config(struct device_node *np)
pio_map = of_get_property(pio, "pio-map", &pio_map_len);
if (pio_map == NULL) {
printk(KERN_ERR "pio-map is not set!\n");
- return -1;
+ goto err_node_put;
}
pio_map_len /= sizeof(unsigned int);
if ((pio_map_len % 6) != 0) {
printk(KERN_ERR "pio-map format wrong!\n");
- return -1;
+ goto err_node_put;
}
while (pio_map_len > 0) {
@@ -182,5 +182,9 @@ int par_io_of_config(struct device_node *np)
}
of_node_put(pio);
return 0;
+
+err_node_put:
+ of_node_put(pio);
+ return -1;
}
EXPORT_SYMBOL(par_io_of_config);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-29 1:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 1:50 [PATCH] soc: fsl: qe: Fix refcount leak in par_io_of_config Zheng Yongjun
-- strict thread matches above, loose matches on Subject: below --
2022-04-03 12:19 Miaoqian Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).