Commit cc95527c authored by Nishka Dasgupta's avatar Nishka Dasgupta Committed by Dmitry Torokhov

Input: mtk-pmic-keys - 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. Hence 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 avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 071cfc43
...@@ -286,8 +286,10 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) ...@@ -286,8 +286,10 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index]; keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index];
keys->keys[index].irq = platform_get_irq(pdev, index); keys->keys[index].irq = platform_get_irq(pdev, index);
if (keys->keys[index].irq < 0) if (keys->keys[index].irq < 0) {
of_node_put(child);
return keys->keys[index].irq; return keys->keys[index].irq;
}
error = of_property_read_u32(child, error = of_property_read_u32(child,
"linux,keycodes", &keys->keys[index].keycode); "linux,keycodes", &keys->keys[index].keycode);
...@@ -295,6 +297,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) ...@@ -295,6 +297,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
dev_err(keys->dev, dev_err(keys->dev,
"failed to read key:%d linux,keycode property: %d\n", "failed to read key:%d linux,keycode property: %d\n",
index, error); index, error);
of_node_put(child);
return error; return error;
} }
...@@ -302,8 +305,10 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) ...@@ -302,8 +305,10 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
keys->keys[index].wakeup = true; keys->keys[index].wakeup = true;
error = mtk_pmic_key_setup(keys, &keys->keys[index]); error = mtk_pmic_key_setup(keys, &keys->keys[index]);
if (error) if (error) {
of_node_put(child);
return error; return error;
}
index++; index++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment