Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp3664677imd; Mon, 29 Oct 2018 10:24:59 -0700 (PDT) X-Google-Smtp-Source: AJdET5dEaWr3Vb/ZJzkQeV2xLgomSWRMTtScnNkULdD6feQHCAUpgmwJ++6ILmNke+1HuH9ZTkgl X-Received: by 2002:a63:e00d:: with SMTP id e13-v6mr14387987pgh.114.1540833899288; Mon, 29 Oct 2018 10:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540833899; cv=none; d=google.com; s=arc-20160816; b=re4Cdk4Dp3b54okLdHdXaXfCW8c3boIBJXbYq7YZFCUkGU4fjko21rfeo2/sjMzRqb VgjiKebhhOXyPB8lJMb91++O4dq7fQ4XUQvdZb1491mi3iRJ86LsoQf1wL7x0ceLAkv7 KFPft+pCdS4YdmBOzHVuiYEgUY/aqNsYY0fvJO3iyskXSypMM26pJsqC7IjKaHgP3ZG4 GsUjANl/0aqF96OwmtzcxJa3eXm1bl74rpozp35Wis//jNGKT3aQ0Dhe72MW/NZIxyJP lq3bHu/TqMkLl2wl4696/fHRssgPs2houlhvC9gijEXqoLSlOTXZpBvqDGpgWLK9dVGj e3JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature; bh=LCPEjAt8s6iD878SvUT2rQbrw+isHozPuM0QhKpxszc=; b=TmY+cJWLLtgJL1+K2ZgzVtQJ65o5m3OAX+jTliodG/7wHU23u+TnRq5ef8kzIxvJy9 Pq7S276YoDMLLkFvoSJMs3aLc42F9hWtefnviQ25+4uL/xcESqhSZ/TVc7H4myDTatSH gJSyMVLvXPmF+b6UAXx/6072ODo5o2FNpQwd7IvECoxIm8nkDDxw8SOpYmmjQPkT5RG4 4ifDY7sTQPAKPHMdPL6RAiaGXDfSX4w6kVcd1tgu2k7VcasR0JdB0wDZdT3p8Zvpwp1y C8hPZWv69+VLCUHyPVn801iPHSO75ogu0/AJGHTq0SDAC14iUb/TUDlB1IqIKDahJnqf z5nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MJBtKs9G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12-v6si20081162pls.367.2018.10.29.10.24.43; Mon, 29 Oct 2018 10:24:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MJBtKs9G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727638AbeJ3CNU (ORCPT + 99 others); Mon, 29 Oct 2018 22:13:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:34780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726212AbeJ3CNU (ORCPT ); Mon, 29 Oct 2018 22:13:20 -0400 Received: from localhost (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0532C20657; Mon, 29 Oct 2018 17:23:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540833828; bh=w1YnWt+AnwXv/iS2szCUWKOpLQDHkLKhFgwvClfS/eA=; h=To:From:In-Reply-To:Cc:References:Subject:Date:From; b=MJBtKs9GnpyaQ0ZEieMECWGU9IX3goI8lnsgPjeQrGhQwWcbRJJ/6lzfYAP3biVAe w5HB88qL6AbOwRLQZLb/47qCAp/9Y1Qe0ULzZ9F/X8leUWeHzUUrI2nwhsoDJUaEV1 Z+Bi4QsHJu3p4CrLmpwW+8i+0Nak4O8aiBgeuQfI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Yi Wang , paul.burton@mips.com From: Stephen Boyd In-Reply-To: <1540801907-31544-1-git-send-email-wang.yi59@zte.com.cn> Cc: mturquette@baylibre.com, linux-mips@linux-mips.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, Yi Wang References: <1540801907-31544-1-git-send-email-wang.yi59@zte.com.cn> Message-ID: <154083382731.98144.10932242759017894372@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH v2] clk: boston: fix possible memory leak in clk_boston_setup() Date: Mon, 29 Oct 2018 10:23:47 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Yi Wang (2018-10-29 01:31:47) > 'onecell' is malloced in clk_boston_setup(), but is not freed > before leaving from the error handling cases. How did you find this? Visual inspection? Some coccinelle script? > = > Signed-off-by: Yi Wang > --- > v2: fix syntax issue in comment, thanks to Sergei. > = > drivers/clk/imgtec/clk-boston.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > = > diff --git a/drivers/clk/imgtec/clk-boston.c b/drivers/clk/imgtec/clk-bos= ton.c > index 15af423..f5d54a6 100644 > --- a/drivers/clk/imgtec/clk-boston.c > +++ b/drivers/clk/imgtec/clk-boston.c > @@ -73,27 +73,32 @@ static void __init clk_boston_setup(struct device_nod= e *np) > hw =3D clk_hw_register_fixed_rate(NULL, "input", NULL, 0, in_freq= ); > if (IS_ERR(hw)) { > pr_err("failed to register input clock: %ld\n", PTR_ERR(h= w)); > - return; > + goto error; > } > onecell->hws[BOSTON_CLK_INPUT] =3D hw; > = > hw =3D clk_hw_register_fixed_rate(NULL, "sys", "input", 0, sys_fr= eq); > if (IS_ERR(hw)) { > pr_err("failed to register sys clock: %ld\n", PTR_ERR(hw)= ); > - return; > + goto error; > } > onecell->hws[BOSTON_CLK_SYS] =3D hw; > = > hw =3D clk_hw_register_fixed_rate(NULL, "cpu", "input", 0, cpu_fr= eq); > if (IS_ERR(hw)) { > pr_err("failed to register cpu clock: %ld\n", PTR_ERR(hw)= ); > - return; > + goto error; > } > onecell->hws[BOSTON_CLK_CPU] =3D hw; > = > err =3D of_clk_add_hw_provider(np, of_clk_hw_onecell_get, onecell= ); > if (err) > pr_err("failed to add DT provider: %d\n", err); > + > + return; > + > +error: > + kfree(onecell); Ok, sure. But then clks are still left registered on failure?