| Message ID | 20221017165028.4194254-1-dario.binacchi@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-amarula+bncBCQ4XFG47UFRBWEPW2NAMGQEQBDRZNY@amarulasolutions.com> X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 36F604147A for <linux-amarula@patchwork.amarulasolutions.com>; Mon, 17 Oct 2022 18:50:33 +0200 (CEST) Received: by mail-ej1-f70.google.com with SMTP id he6-20020a1709073d8600b0078e20190301sf3893337ejc.22 for <linux-amarula@patchwork.amarulasolutions.com>; Mon, 17 Oct 2022 09:50:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666025433; cv=pass; d=google.com; s=arc-20160816; b=Ffay+cxgNpNU4MFEzI5IeetmQUdu0bhTN2LYVfl56R6RO68WBMWhBahmqBKLAR87JB wEgUSyii2uHcGBm8kE+ca+AoMiLXFM8SEyXyAQdGKJ0d/uEBhDgJk4cbp3lpAuuVpvtq BUCUFyAwMWSqwYLoTLYcqJ/vHb7fvyPO2br+RhVssDAl490b7uR3IL+gxx/zF8GrMBmm S1RSclcBjSaK8qEVLOxbY9JeEV3cmUozw9J60CWKm3i9VPUIjEP5W4MvvgBD/ZarSaoZ ZGs24gU2aJfVNIWIwfZO7f78RxOt0PQjCoavu/AtaBEGKWkdYs6W7n62r8SyhXlmFYMw 2oKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=iMDdvVFXJqAWLiPxGaHz8YyAb0VjGrgDHokpM4xv1hw=; b=rimltKTAJUJuw6F8wBo+Ghg+zbR8Lh3wlMO6NF4pLzc+d3dvYu/80OY94Gv2dgN3ui ILVOiza7sopUBp89NyQVVr8S77vGvQCkudHfq1JJWiDtbVlt+L8r4V3Osbe6io/PF1P6 aZMV5beaF+qJg8WCNk1sWg5h3OpywBxSW80YRSOwYns2auTlVdD2Vp2+O28OBKLibPYn MhQw+czlQWTTBRTKygdSV3IqsVS8qhcvuRy4o07msde0XBAor3TdWMe56xMkE2wMKII1 z68f1JtBijxwLW6/+L4HXJRrJe3+aYDFeXzZmtV5s5uajYY9qI6kgbhKqb42isRLhyDQ fMtg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KuVlSmIb; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=iMDdvVFXJqAWLiPxGaHz8YyAb0VjGrgDHokpM4xv1hw=; b=rGAesh9rHFyoq6miP3LVyz77YbtGD3LGad0N+Lf4DZ07epNcrc16lTMhjblJUG18pM /zdUcc+aIH3geWJHTnFac3FhLFbVh4fOVA186xdJOKOdIciIH5AJaQY3vqBscxvhgWGu z/j2NsOqlnZLtiqv3NdSxlBEp3pBQEGwQEaqc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iMDdvVFXJqAWLiPxGaHz8YyAb0VjGrgDHokpM4xv1hw=; b=Bn2b9N3AmVMIx8p+zGP/ot75YboXb1IRg/mFRDlZfpYm3bH/mcWRi5X8Ccg/oNa0Al XIThc7SNtPKnyltMRc/E4nKdnDtgciVBsTvm1wEJHAEFwQTuPClFVC2YDl2T/u/4J8rd nVlyJlNrcRZzr1JM7QejXYsr29lGSFzz8oc5jaqZynxLclNux9DQdaERDnhxSaA7Ghzr GPAvdSZKwQLOKcNwE4fbnkBoep/VrjOit5WjL+0EhOD+sQXIIZlsx+5YnLiFd9mtajnm cdTcnh6zlauId8DnA5j+SrMhVRz9PmXHl/WiyBIACx1KQtdCo7/5mvfxx2egQWwL8K94 ZWtg== X-Gm-Message-State: ACrzQf2hZKF/yAkwO+Mg+MrS1q3AhsRqaEZRrjveODJ6JD46GsWfzR5j xMxZH8hjUJlmTjZpaSyhvtkD/Xy8 X-Google-Smtp-Source: AMsMyM5pEJm1Vt2BDpApQElvMs3GpTFBBEKV+DrCsO8ZxVIGUNmxRqrHHelOdzWL6gbVeb9N7dULyg== X-Received: by 2002:a05:6402:ca:b0:45c:dbdd:8143 with SMTP id i10-20020a05640200ca00b0045cdbdd8143mr11103308edu.213.1666025433003; Mon, 17 Oct 2022 09:50:33 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:c301:b0:783:b20:46a0 with SMTP id s1-20020a170906c30100b007830b2046a0ls6057093ejz.6.-pod-prod-gmail; Mon, 17 Oct 2022 09:50:32 -0700 (PDT) X-Received: by 2002:a17:907:daa:b0:78d:9bc9:7d7a with SMTP id go42-20020a1709070daa00b0078d9bc97d7amr9175806ejc.567.1666025431941; Mon, 17 Oct 2022 09:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666025431; cv=none; d=google.com; s=arc-20160816; b=Lx3Zit1lw4HScRKKQQ7DPdnoy/eloR155vEBSoj5yMnM2Vc85OLru1cheCf8OuFJyQ F6lvaxDg51xLwLRgr9bqFdLQy8m6ibv7HA9hQ2n0rYSmJXJpMMysEv8iuPQyuPP6Wu+4 j21a/bAVaoo9gbynkwaLgSR1A69sKh36/RBv4f/Ahp7MvXG2wA1o31JTmXt16LAvq+tU RizJzD8DJ5LkQlHYrMRtt0bC16t8EdpvXJBO7GNnAFag4sbHJcts/QzXyH4PlTi3e1CI wUzd1vuu2dPsg0OmjlY6jXnsg1Jg+Oti6JHh/ptOrKAQM6czG6oASCMst/Qc+sU2B3kv VYGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=drbnWG6FnPMKy+1KjZWfuBI6Wm/8lttgnizdA5I4wh0=; b=DbCtcXX2pF2tHCdeIWMpF+TlB0A/jEp7wvcycEpQNLtNX7Qf25S+9t37bMJX+i2Fds 2OgfEHTXlr2t+wUvDSI5JR2lhHHmwZvan262uldHya/gtzRIlGvplqqWhWg/Mv1EW3xx o9I5EW7T/cHIWDenGlOP3zSOEl8vYb0nozzcnhdC93LPfLgnVZi3mY76gATBjVc41q1Z 5WGSY5N3Je+g49G7Mn8OCDJdK7RNGEBaG8NITuqFYXkt+iv3TFiqVoht9Q8aEuq0ruok eNv7TZTg1ZRaxi66om1sO5EGpUxVXWjaOhfLi4L8pVo1NQr5b1j9Luc3b0VOwcBWi9XE uX1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KuVlSmIb; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id b25-20020a17090630d900b0078da3cc381esor3892683ejb.112.2022.10.17.09.50.31 for <linux-amarula@amarulasolutions.com> (Google Transport Security); Mon, 17 Oct 2022 09:50:31 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:2d1e:b0:78e:2c3b:559f with SMTP id gs30-20020a1709072d1e00b0078e2c3b559fmr9375041ejc.435.1666025431720; Mon, 17 Oct 2022 09:50:31 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-244-101-110.retail.telecomitalia.it. [95.244.101.110]) by smtp.gmail.com with ESMTPSA id o7-20020a170906774700b0077086d2db8esm6473027ejn.140.2022.10.17.09.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 09:50:31 -0700 (PDT) From: Dario Binacchi <dario.binacchi@amarulasolutions.com> To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Amarula patchwork <linux-amarula@amarulasolutions.com>, Dario Binacchi <dario.binacchi@amarulasolutions.com>, Allison Randal <allison@lohutok.net>, Miaoqian Lin <linmq006@gmail.com>, Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, Tero Kristo <kristo@kernel.org>, Thomas Gleixner <tglx@linutronix.de>, Tony Lindgren <tony@atomide.com>, linux-clk@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH] clk: ti: dra7-atl: don't allocate `parent_names' variable Date: Mon, 17 Oct 2022 18:50:28 +0200 Message-Id: <20221017165028.4194254-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KuVlSmIb; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: <linux-amarula.amarulasolutions.com> X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>, <mailto:linux-amarula@amarulasolutions.com> List-Help: <https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>, <mailto:linux-amarula+help@amarulasolutions.com> List-Archive: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/> List-Unsubscribe: <mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>, <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe> |
| Series |
clk: ti: dra7-atl: don't allocate `parent_names' variable
|
|
Commit Message
Dario Binacchi
Oct. 17, 2022, 4:50 p.m. UTC
The `parent_names' variable was freed also in case of kzalloc() error.
Instead of modifying the code to perform a proper memory release, I
decided to fix the bug by not allocating memory.
Since only one parent name is referenced, it is not necessary to
allocate this variable at runtime and therefore you can avoid calling
the kzalloc() function. This simplifies the code (even calls to kfree
can be removed) and improves the performance of the routine.
Note: Although no operation is performed by kfree() on a NULL pointer,
it was however suboptimal and semantically wrong doing it.
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
drivers/clk/ti/clk-dra7-atl.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
Comments
Hi Dario,
I love your patch! Yet something to improve:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on linus/master v6.1-rc1 next-20221017]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dario-Binacchi/clk-ti-dra7-atl-don-t-allocate-parent_names-variable/20221018-005059
base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
patch link: https://lore.kernel.org/r/20221017165028.4194254-1-dario.binacchi%40amarulasolutions.com
patch subject: [PATCH] clk: ti: dra7-atl: don't allocate `parent_names' variable
config: arm-defconfig
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/9eca9eab009687ea2b8cc0d262de7786b6d449b9
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Dario-Binacchi/clk-ti-dra7-atl-don-t-allocate-parent_names-variable/20221018-005059
git checkout 9eca9eab009687ea2b8cc0d262de7786b6d449b9
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/clk/ti/clk-dra7-atl.c: In function 'of_dra7_atl_clock_setup':
>> drivers/clk/ti/clk-dra7-atl.c:190:27: error: assignment to 'const char * const*' from incompatible pointer type 'const char *' [-Werror=incompatible-pointer-types]
190 | init.parent_names = of_clk_get_parent_name(node, 0);
| ^
cc1: some warnings being treated as errors
vim +190 drivers/clk/ti/clk-dra7-atl.c
162
163 static void __init of_dra7_atl_clock_setup(struct device_node *node)
164 {
165 struct dra7_atl_desc *clk_hw = NULL;
166 struct clk_init_data init = { NULL };
167 const char *name;
168 struct clk *clk;
169
170 clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
171 if (!clk_hw) {
172 pr_err("%s: could not allocate dra7_atl_desc\n", __func__);
173 return;
174 }
175
176 clk_hw->hw.init = &init;
177 clk_hw->divider = 1;
178 name = ti_dt_clk_name(node);
179 init.name = name;
180 init.ops = &atl_clk_ops;
181 init.flags = CLK_IGNORE_UNUSED;
182 init.num_parents = of_clk_get_parent_count(node);
183
184 if (init.num_parents != 1) {
185 pr_err("%s: atl clock %pOFn must have 1 parent\n", __func__,
186 node);
187 goto cleanup;
188 }
189
> 190 init.parent_names = of_clk_get_parent_name(node, 0);
191
192 clk = ti_clk_register(NULL, &clk_hw->hw, name);
193 if (!IS_ERR(clk)) {
194 of_clk_add_provider(node, of_clk_src_simple_get, clk);
195 return;
196 }
197
198 cleanup:
199 kfree(clk_hw);
200 }
201 CLK_OF_DECLARE(dra7_atl_clock, "ti,dra7-atl-clock", of_dra7_atl_clock_setup);
202
diff --git a/drivers/clk/ti/clk-dra7-atl.c b/drivers/clk/ti/clk-dra7-atl.c index ff4d6a951681..ec2473069143 100644 --- a/drivers/clk/ti/clk-dra7-atl.c +++ b/drivers/clk/ti/clk-dra7-atl.c @@ -164,7 +164,6 @@ static void __init of_dra7_atl_clock_setup(struct device_node *node) { struct dra7_atl_desc *clk_hw = NULL; struct clk_init_data init = { NULL }; - const char **parent_names = NULL; const char *name; struct clk *clk; @@ -188,24 +187,15 @@ static void __init of_dra7_atl_clock_setup(struct device_node *node) goto cleanup; } - parent_names = kzalloc(sizeof(char *), GFP_KERNEL); - - if (!parent_names) - goto cleanup; - - parent_names[0] = of_clk_get_parent_name(node, 0); - - init.parent_names = parent_names; + init.parent_names = of_clk_get_parent_name(node, 0); clk = ti_clk_register(NULL, &clk_hw->hw, name); - if (!IS_ERR(clk)) { of_clk_add_provider(node, of_clk_src_simple_get, clk); - kfree(parent_names); return; } + cleanup: - kfree(parent_names); kfree(clk_hw); } CLK_OF_DECLARE(dra7_atl_clock, "ti,dra7-atl-clock", of_dra7_atl_clock_setup);