提交 c5ad5e84 编写于 作者: N Nishka Dasgupta 提交者: Xie XiuQi

irqchip/irq-mbigen: Add of_node_put() before return

mainline inclusion
from mainline-5.3-rc3
commit 321275f0d8f5
category: bugfix
bugzilla: 20161
CVE: NA

-------------------------------------------------

Each iteration of for_each_child_of_node puts the previous node, but
in the case of a return from the middle of the loop, there is no put,
thus causing a memory leak. Add an of_node_put before the return in
three places.
Issue found with Coccinelle.
Signed-off-by: NNishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: NMarc Zyngier <maz@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 cebf9217
...@@ -252,12 +252,15 @@ static int mbigen_of_create_domain(struct platform_device *pdev, ...@@ -252,12 +252,15 @@ static int mbigen_of_create_domain(struct platform_device *pdev,
parent = platform_bus_type.dev_root; parent = platform_bus_type.dev_root;
child = of_platform_device_create(np, NULL, parent); child = of_platform_device_create(np, NULL, parent);
if (!child) if (!child) {
of_node_put(np);
return -ENOMEM; return -ENOMEM;
}
if (of_property_read_u32(child->dev.of_node, "num-pins", if (of_property_read_u32(child->dev.of_node, "num-pins",
&num_pins) < 0) { &num_pins) < 0) {
dev_err(&pdev->dev, "No num-pins property\n"); dev_err(&pdev->dev, "No num-pins property\n");
of_node_put(np);
return -EINVAL; return -EINVAL;
} }
...@@ -265,8 +268,10 @@ static int mbigen_of_create_domain(struct platform_device *pdev, ...@@ -265,8 +268,10 @@ static int mbigen_of_create_domain(struct platform_device *pdev,
mbigen_write_msg, mbigen_write_msg,
&mbigen_domain_ops, &mbigen_domain_ops,
mgn_chip); mgn_chip);
if (!domain) if (!domain) {
of_node_put(np);
return -ENOMEM; return -ENOMEM;
}
} }
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册