Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751883AbdIURsg (ORCPT ); Thu, 21 Sep 2017 13:48:36 -0400 Received: from mail-pg0-f51.google.com ([74.125.83.51]:44174 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751640AbdIURse (ORCPT ); Thu, 21 Sep 2017 13:48:34 -0400 X-Google-Smtp-Source: AOwi7QA3IDxakL5B+238GtafNuhHDxJd2TZE1gS+fAXtvYqMy3X/8P5EM1W0QgVSjuQTxSHJLI38Xg== Date: Thu, 21 Sep 2017 10:48:32 -0700 From: Viresh Kumar To: Arvind Yadav Cc: vireshk@kernel.org, nm@ti.com, sboyd@codeaurora.org, rjw@rjwysocki.net, pavel@ucw.cz, len.brown@intel.com, gregkh@linuxfoundation.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree Message-ID: <20170921174832.GA17243@ubuntu> References: <6cdcf0c59a9a045941188356a2c4973c876c9fc6.1505972576.git.arvind.yadav.cs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6cdcf0c59a9a045941188356a2c4973c876c9fc6.1505972576.git.arvind.yadav.cs@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1133 Lines: 42 On 21-09-17, 11:15, Arvind Yadav wrote: > Use snprintf to avoid unnecessary initializations, avoid calling kfree. > Suggested-by: Joe Perches > Signed-off-by: Arvind Yadav > --- > changes in v2: > Remove kasprintf instead of error checking. > > drivers/base/power/opp/debugfs.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/base/power/opp/debugfs.c b/drivers/base/power/opp/debugfs.c > index 81cf120..a2fa785 100644 > --- a/drivers/base/power/opp/debugfs.c > +++ b/drivers/base/power/opp/debugfs.c > @@ -41,16 +41,15 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp, > { > struct dentry *d; > int i; > - char *name; > > for (i = 0; i < opp_table->regulator_count; i++) { > - name = kasprintf(GFP_KERNEL, "supply-%d", i); > + char name[15]; > + > + snprintf(name, sizeof(name), "supply-%d", i); > > /* Create per-opp directory */ > d = debugfs_create_dir(name, pdentry); > > - kfree(name); > - > if (!d) > return false; Acked-by: Viresh Kumar -- viresh