Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1736367 > unrolled thread

[PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree

Started byArvind Yadav <arvind.yadav.cs@gmail.com>
First post2017-09-21 07:50 +0200
Last post2017-09-22 09:20 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree Arvind Yadav <arvind.yadav.cs@gmail.com> - 2017-09-21 07:50 +0200
    Re: [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree Viresh Kumar <viresh.kumar@linaro.org> - 2017-09-21 19:50 +0200
    Re: [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree Stephen Boyd <sboyd@codeaurora.org> - 2017-09-22 09:20 +0200

#1736367 — [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree

FromArvind Yadav <arvind.yadav.cs@gmail.com>
Date2017-09-21 07:50 +0200
Subject[PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree
Message-ID<us2x4-55T-5@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1736979

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-09-21 19:50 +0200
Message-ID<usdLQ-41H-17@gated-at.bofh.it>
In reply to#1736367
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

[toc] | [prev] | [next] | [standalone]


#1737223

FromStephen Boyd <sboyd@codeaurora.org>
Date2017-09-22 09:20 +0200
Message-ID<usqpH-3eG-9@gated-at.bofh.it>
In reply to#1736367
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web