From 507aaefcf7e90b2955273ce13ee2579835b3a81c Mon Sep 17 00:00:00 2001 From: David Collins Date: Mon, 4 Jan 2021 11:10:03 -0800 Subject: [PATCH] regulator: rpmh-regulator: fix rpmh_regulator_init_vreg_supply memory leak Commit 29c41d5c47cb ("regulator: rpmh-regulator: support parent supply specification in subnodes") introduced a memory leak in the function rpmh_regulator_init_vreg_supply() due to 'buf' not being freed in the new 'else if' statement. Fix this memory leak by freeing 'buf' correctly. Change-Id: If2748b595d8ae3a4564a2956a67aeda476975309 Signed-off-by: David Collins --- drivers/regulator/rpmh-regulator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/rpmh-regulator.c b/drivers/regulator/rpmh-regulator.c index 6d50b6e577f3..b0bea3a21b03 100644 --- a/drivers/regulator/rpmh-regulator.c +++ b/drivers/regulator/rpmh-regulator.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ +/* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ #define pr_fmt(fmt) "%s: " fmt, __func__ @@ -1673,6 +1673,7 @@ static int rpmh_regulator_init_vreg_supply(struct rpmh_vreg *vreg) vreg->rdesc.supply_name = buf; } else if (of_find_property(vreg->of_node, "vin-supply", NULL)) { + kfree(buf); vreg->rdesc.supply_name = "vin"; } else { kfree(buf);