Skip to content

Commit

Permalink
ARM: mvebu: fix a leaked reference by adding missing of_node_put
Browse files Browse the repository at this point in the history
The call to of_get_next_child returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./arch/arm/mach-mvebu/pm-board.c:135:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 88, but without a corresponding object release within this functio

Signed-off-by: Wen Yang <[email protected]>
Cc: Jason Cooper <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Gregory Clement <[email protected]>
Cc: Sebastian Hesselbarth <[email protected]>
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Gregory CLEMENT <[email protected]>
  • Loading branch information
taskset authored and gclement committed Apr 30, 2019
1 parent 7971cc4 commit 8f11b5a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions arch/arm/mach-mvebu/pm-board.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void mvebu_armada_pm_enter(void __iomem *sdram_reg, u32 srcmd)
static int __init mvebu_armada_pm_init(void)
{
struct device_node *np;
struct device_node *gpio_ctrl_np;
struct device_node *gpio_ctrl_np = NULL;
int ret = 0, i;

if (!of_machine_is_compatible("marvell,axp-gp"))
Expand Down Expand Up @@ -126,18 +126,23 @@ static int __init mvebu_armada_pm_init(void)
goto out;
}

if (gpio_ctrl_np)
of_node_put(gpio_ctrl_np);
gpio_ctrl_np = args.np;
pic_raw_gpios[i] = args.args[0];
}

gpio_ctrl = of_iomap(gpio_ctrl_np, 0);
if (!gpio_ctrl)
return -ENOMEM;
if (!gpio_ctrl) {
ret = -ENOMEM;
goto out;
}

mvebu_pm_suspend_init(mvebu_armada_pm_enter);

out:
of_node_put(np);
of_node_put(gpio_ctrl_np);
return ret;
}

Expand Down

0 comments on commit 8f11b5a

Please sign in to comment.