From: Fabio Estevam <fabio.este...@freescale.com> Currently when of_get_parent() or syscon_node_to_regmap() fail 'kfree(sreg->name)' is not called, which is incorrect.
Fix this by jumping to 'anatop_probe_end' instead. While at it, make 'anatop_probe_end' to be executed only on the error path, so that the code can be a bit easier to follow. Signed-off-by: Fabio Estevam <fabio.este...@freescale.com> --- Changes since v2: - Fix the error path for of_get_parent() or syscon_node_to_regmap(). drivers/regulator/anatop-regulator.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index c734d09..88d95cd 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c @@ -132,12 +132,16 @@ static int anatop_regulator_probe(struct platform_device *pdev) rdesc->owner = THIS_MODULE; anatop_np = of_get_parent(np); - if (!anatop_np) - return -ENODEV; + if (!anatop_np) { + ret = -ENODEV; + goto anatop_probe_end; + } sreg->anatop = syscon_node_to_regmap(anatop_np); of_node_put(anatop_np); - if (IS_ERR(sreg->anatop)) - return PTR_ERR(sreg->anatop); + if (IS_ERR(sreg->anatop)) { + ret = PTR_ERR(sreg->anatop); + goto anatop_probe_end; + } ret = of_property_read_u32(np, "anatop-reg-offset", &sreg->control_reg); @@ -210,9 +214,10 @@ static int anatop_regulator_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rdev); + return 0; + anatop_probe_end: - if (ret) - kfree(sreg->name); + kfree(sreg->name); return ret; } -- 1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/