Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp142119ybz; Tue, 28 Apr 2020 20:17:14 -0700 (PDT) X-Google-Smtp-Source: APiQypLJYEMAdD62AifWVr2ejA4O5/Hwk1tRkZzEiiYEH6yAJHsPIZgjdDRhA+CxczWVCn3faR1E X-Received: by 2002:a50:e8cb:: with SMTP id l11mr772635edn.174.1588130234131; Tue, 28 Apr 2020 20:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588130234; cv=none; d=google.com; s=arc-20160816; b=TKUzkI1xq0ry+MoEXQORfuZoDsE3rSOW1tp2v6FQ2awLTRvaoMMRET2lZ+yvGg97i1 MNNTBFfIMFELph+ouEcEZcqLtegXsODGdgJKY4x+kArAQOmzZdrhaBSeubnKz8UGSYgv VY9uZviSZhm4PUFNFGrSa2C0sbKDS9C+d/8nzRQvM0zQaNSyJcOoQQ5wDw/379tk3X6j 5dywduFQ0K5GB9vs/OVRi904+40i8Pd7WNYTt/EqS1kUE+RhuHbRqa1oIg4Ut9fUkmlt usXiFETI+fm4nTjHTiGLwzqXBjPQgbup/wYB73Kkg1fqUt0BNpktL33q+bL8gIcXVQp7 1QEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Ls4gEA4XReOErQmeQV4YGSQ7DOQgTDGVoVJ5ZuypPJQ=; b=Ha4hDE5NiyQOEUKK4dOOa6H5W+qNSR5rXvZwLxFU1cHmVmgoehoN9SWO8gdOf3CCNj 5Cxj3dKGbYfGrLgW0BZO/hQAAKj7laLt8pYxNV05LKfZ2t01N7bajv6+el/pjEBHCjW1 /krWgjORgbDejDr7recHLDqfjKBTzyn1+EScYP4q8u4ocfsxWMqSgG2zYD+6py/gn6ME nBqHgQxxCCfbe2Ug0NrNLqrHqbVYI1kgrvAfco7Jgmm3eEpiBzMWrN9w9zPCLUfarDNT 3NKje/DL7fqximG7Oawf864rQFBXuvWVUvqtvDhIhDuMJPFwEK3jTJcDuTaqb2YGnnWv Vhww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l35si2731778edl.187.2020.04.28.20.16.50; Tue, 28 Apr 2020 20:17:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726677AbgD2DO0 (ORCPT + 99 others); Tue, 28 Apr 2020 23:14:26 -0400 Received: from mail-m17613.qiye.163.com ([59.111.176.13]:27962 "EHLO mail-m17613.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgD2DO0 (ORCPT ); Tue, 28 Apr 2020 23:14:26 -0400 Received: from ubuntu.localdomain (unknown [157.0.31.122]) by mail-m17613.qiye.163.com (Hmail) with ESMTPA id 52F79481854; Wed, 29 Apr 2020 11:14:23 +0800 (CST) From: Bernard Zhao To: Neil Armstrong , Jerome Brunet , Michael Turquette , Stephen Boyd , Kevin Hilman , linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Bernard Zhao Subject: [PATCH] clk/meson: fixes memleak issue in init err branch Date: Tue, 28 Apr 2020 20:14:15 -0700 Message-Id: <20200429031416.3900-1-bernard@vivo.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZT1VPTkpLS0tJSkhNSUhLTllXWShZQU hPN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MC46Lyo5DTg*ME5WDTA0OSwr SRAaCzNVSlVKTkNDSkhLS01ITk1NVTMWGhIXVRkeCRUaCR87DRINFFUYFBZFWVdZEgtZQVlKTkxV S1VISlVKSUlZV1kIAVlBSUxCQjcG X-HM-Tid: 0a71c3eda48f93bakuws52f79481854 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In common init function, when run into err branch, we didn`t use kfree to release kzmalloc area, this may bring in memleak Signed-off-by: Bernard Zhao --- drivers/clk/meson/meson8b.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c index 34a70c4b4899..0f07d5a4cd16 100644 --- a/drivers/clk/meson/meson8b.c +++ b/drivers/clk/meson/meson8b.c @@ -3687,6 +3687,7 @@ static void __init meson8b_clkc_init_common(struct device_node *np, if (ret) { pr_err("%s: Failed to register clkc reset controller: %d\n", __func__, ret); + kfree(rstc); return; } @@ -3710,8 +3711,10 @@ static void __init meson8b_clkc_init_common(struct device_node *np, continue; ret = of_clk_hw_register(np, clk_hw_onecell_data->hws[i]); - if (ret) + if (ret) { + kfree(rstc); return; + } } meson8b_cpu_nb_data.cpu_clk = clk_hw_onecell_data->hws[CLKID_CPUCLK]; @@ -3727,13 +3730,16 @@ static void __init meson8b_clkc_init_common(struct device_node *np, if (ret) { pr_err("%s: failed to register the CPU clock notifier\n", __func__); + kfree(rstc); return; } ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_hw_onecell_data); - if (ret) + if (ret) { pr_err("%s: failed to register clock provider\n", __func__); + kfree(rstc); + } } static void __init meson8_clkc_init(struct device_node *np) -- 2.26.2