diff mbox

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

Message ID 6cdcf0c59a9a045941188356a2c4973c876c9fc6.1505972576.git.arvind.yadav.cs@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

Arvind Yadav Sept. 21, 2017, 5:45 a.m. UTC
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(-)

Comments

Viresh Kumar Sept. 21, 2017, 5:48 p.m. UTC | #1
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>
Stephen Boyd Sept. 22, 2017, 7:17 a.m. UTC | #2
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>
diff mbox

Patch

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;