linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree
@ 2017-09-21  5:45 Arvind Yadav
  2017-09-21 17:48 ` Viresh Kumar
  2017-09-22  7:17 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Arvind Yadav @ 2017-09-21  5:45 UTC (permalink / raw)
  To: vireshk, nm, sboyd, rjw, pavel, len.brown, gregkh; +Cc: linux-pm, linux-kernel

Use snprintf to avoid unnecessary initializations, avoid calling kfree.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
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;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree
  2017-09-21  5:45 [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree Arvind Yadav
@ 2017-09-21 17:48 ` Viresh Kumar
  2017-09-22  7:17 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2017-09-21 17:48 UTC (permalink / raw)
  To: Arvind Yadav
  Cc: vireshk, nm, sboyd, rjw, pavel, len.brown, gregkh, linux-pm,
	linux-kernel

On 21-09-17, 11:15, Arvind Yadav wrote:
> Use snprintf to avoid unnecessary initializations, avoid calling kfree.
> 

Suggested-by: Joe Perches <joe@perches.com>

> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
> 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.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree
  2017-09-21  5:45 [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree Arvind Yadav
  2017-09-21 17:48 ` Viresh Kumar
@ 2017-09-22  7:17 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2017-09-22  7:17 UTC (permalink / raw)
  To: Arvind Yadav
  Cc: vireshk, nm, rjw, pavel, len.brown, gregkh, linux-pm,
	linux-kernel

On 09/21, Arvind Yadav wrote:
> Use snprintf to avoid unnecessary initializations, avoid calling kfree.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---

Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-22  7:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-21  5:45 [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree Arvind Yadav
2017-09-21 17:48 ` Viresh Kumar
2017-09-22  7:17 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).