Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 321275f0 authored by Nishka Dasgupta's avatar Nishka Dasgupta Committed by Marc Zyngier
Browse files

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



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: default avatarNishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent 34f8eb92
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -252,12 +252,15 @@ static int mbigen_of_create_domain(struct platform_device *pdev,

		parent = platform_bus_type.dev_root;
		child = of_platform_device_create(np, NULL, parent);
		if (!child)
		if (!child) {
			of_node_put(np);
			return -ENOMEM;
		}

		if (of_property_read_u32(child->dev.of_node, "num-pins",
					 &num_pins) < 0) {
			dev_err(&pdev->dev, "No num-pins property\n");
			of_node_put(np);
			return -EINVAL;
		}

@@ -265,9 +268,11 @@ static int mbigen_of_create_domain(struct platform_device *pdev,
							   mbigen_write_msg,
							   &mbigen_domain_ops,
							   mgn_chip);
		if (!domain)
		if (!domain) {
			of_node_put(np);
			return -ENOMEM;
		}
	}

	return 0;
}