All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM / OPP: Handle return value of kasprintf
@ 2017-09-20  6:59 Arvind Yadav
  2017-09-20 11:17 ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Arvind Yadav @ 2017-09-20  6:59 UTC (permalink / raw)
  To: vireshk, nm, sboyd, rjw, pavel, len.brown, gregkh; +Cc: linux-pm, linux-kernel

kasprintf() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/base/power/opp/debugfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/base/power/opp/debugfs.c b/drivers/base/power/opp/debugfs.c
index 81cf120..226d6ae 100644
--- a/drivers/base/power/opp/debugfs.c
+++ b/drivers/base/power/opp/debugfs.c
@@ -45,7 +45,8 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
 
 	for (i = 0; i < opp_table->regulator_count; i++) {
 		name = kasprintf(GFP_KERNEL, "supply-%d", i);
-
+		if (!name)
+			return false;
 		/* Create per-opp directory */
 		d = debugfs_create_dir(name, pdentry);
 
-- 
1.9.1

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

* Re: [PATCH] PM / OPP: Handle return value of kasprintf
  2017-09-20  6:59 [PATCH] PM / OPP: Handle return value of kasprintf Arvind Yadav
@ 2017-09-20 11:17 ` Joe Perches
  2017-09-20 14:49   ` Viresh Kumar
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2017-09-20 11:17 UTC (permalink / raw)
  To: Arvind Yadav, vireshk, nm, sboyd, rjw, pavel, len.brown, gregkh
  Cc: linux-pm, linux-kernel

On Wed, 2017-09-20 at 12:29 +0530, Arvind Yadav wrote:
> kasprintf() can fail here and we must check its return value.
[]
> diff --git a/drivers/base/power/opp/debugfs.c b/drivers/base/power/opp/debugfs.c
[]
> @@ -45,7 +45,8 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
>  
>  	for (i = 0; i < opp_table->regulator_count; i++) {
>  		name = kasprintf(GFP_KERNEL, "supply-%d", i);
> -
> +		if (!name)
> +			return false;
>  		/* Create per-opp directory */
>  		d = debugfs_create_dir(name, pdentry);

Probably more sensible to avoid the kasprintf/kfree
and just have
	char name[20];
on the stack

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

* Re: [PATCH] PM / OPP: Handle return value of kasprintf
  2017-09-20 11:17 ` Joe Perches
@ 2017-09-20 14:49   ` Viresh Kumar
  2017-09-20 16:58     ` arvind
  0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2017-09-20 14:49 UTC (permalink / raw)
  To: Joe Perches
  Cc: Arvind Yadav, vireshk, nm, sboyd, rjw, pavel, len.brown, gregkh,
	linux-pm, linux-kernel

On 20-09-17, 04:17, Joe Perches wrote:
> On Wed, 2017-09-20 at 12:29 +0530, Arvind Yadav wrote:
> > kasprintf() can fail here and we must check its return value.
> []
> > diff --git a/drivers/base/power/opp/debugfs.c b/drivers/base/power/opp/debugfs.c
> []
> > @@ -45,7 +45,8 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
> >  
> >  	for (i = 0; i < opp_table->regulator_count; i++) {
> >  		name = kasprintf(GFP_KERNEL, "supply-%d", i);
> > -
> > +		if (!name)
> > +			return false;
> >  		/* Create per-opp directory */
> >  		d = debugfs_create_dir(name, pdentry);
> 
> Probably more sensible to avoid the kasprintf/kfree
> and just have
> 	char name[20];
> on the stack

Sure.

@Arvind: I will let you write that patch.

-- 
viresh

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

* Re: [PATCH] PM / OPP: Handle return value of kasprintf
  2017-09-20 14:49   ` Viresh Kumar
@ 2017-09-20 16:58     ` arvind
  0 siblings, 0 replies; 4+ messages in thread
From: arvind @ 2017-09-20 16:58 UTC (permalink / raw)
  To: Viresh Kumar, Joe Perches
  Cc: vireshk, nm, sboyd, rjw, pavel, len.brown, gregkh, linux-pm,
	linux-kernel

Hi,

On Wednesday 20 September 2017 08:19 PM, Viresh Kumar wrote:
> On 20-09-17, 04:17, Joe Perches wrote:
>> On Wed, 2017-09-20 at 12:29 +0530, Arvind Yadav wrote:
>>> kasprintf() can fail here and we must check its return value.
>> []
>>> diff --git a/drivers/base/power/opp/debugfs.c b/drivers/base/power/opp/debugfs.c
>> []
>>> @@ -45,7 +45,8 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
>>>   
>>>   	for (i = 0; i < opp_table->regulator_count; i++) {
>>>   		name = kasprintf(GFP_KERNEL, "supply-%d", i);
>>> -
>>> +		if (!name)
>>> +			return false;
>>>   		/* Create per-opp directory */
>>>   		d = debugfs_create_dir(name, pdentry);
>> Probably more sensible to avoid the kasprintf/kfree
>> and just have
>> 	char name[20];
>> on the stack
> Sure.
>
> @Arvind: I will let you write that patch.
Yes, I will do.
>
~arvind

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

end of thread, other threads:[~2017-09-20 16:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-20  6:59 [PATCH] PM / OPP: Handle return value of kasprintf Arvind Yadav
2017-09-20 11:17 ` Joe Perches
2017-09-20 14:49   ` Viresh Kumar
2017-09-20 16:58     ` arvind

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.