From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751347AbcAAFcg (ORCPT ); Fri, 1 Jan 2016 00:32:36 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33809 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750749AbcAAFcb convert rfc822-to-8bit (ORCPT ); Fri, 1 Jan 2016 00:32:31 -0500 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Sudip Mukherjee , "Stephen Boyd" From: Michael Turquette In-Reply-To: <1450852439-366-1-git-send-email-sudipm.mukherjee@gmail.com> Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, "Sudip Mukherjee" References: <1450852439-366-1-git-send-email-sudipm.mukherjee@gmail.com> Message-ID: <20160101053228.21738.40065@quark.deferred.io> User-Agent: alot/0.3.6 Subject: Re: [PATCH] clk: gpio: fix memory leak Date: Thu, 31 Dec 2015 21:32:28 -0800 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Sudip Mukherjee (2015-12-22 22:33:59) > If we fail to allocate parent_name then we are returning but we missed > freeing data which has already been allocated. > > Signed-off-by: Sudip Mukherjee Applied. Thanks, Mike > --- > drivers/clk/clk-gpio.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c > index 335322d..c1baa89 100644 > --- a/drivers/clk/clk-gpio.c > +++ b/drivers/clk/clk-gpio.c > @@ -294,8 +294,10 @@ static void __init of_gpio_clk_setup(struct device_node *node, > num_parents = of_clk_get_parent_count(node); > > parent_names = kcalloc(num_parents, sizeof(char *), GFP_KERNEL); > - if (!parent_names) > + if (!parent_names) { > + kfree(data); > return; > + } > > for (i = 0; i < num_parents; i++) > parent_names[i] = of_clk_get_parent_name(node, i); > -- > 1.9.1 >