linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RE-SEND v1] PM / devfreq: Replace strncpy with strscpy
@ 2020-02-27 17:08 Dmitry Osipenko
  2020-04-17 14:04 ` Dmitry Osipenko
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Osipenko @ 2020-02-27 17:08 UTC (permalink / raw)
  To: MyungJoo Ham, Kyungmin Park, Chanwoo Choi; +Cc: linux-pm, linux-kernel

GCC produces this warning when kernel compiled using `make W=1`:

  warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
  772 |  strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);

The strncpy doesn't take care of NULL-termination of the destination
buffer, while the strscpy does.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/devfreq/devfreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 8494c5f05a73..2011f64bfa3a 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -769,7 +769,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
 	devfreq->dev.release = devfreq_dev_release;
 	INIT_LIST_HEAD(&devfreq->node);
 	devfreq->profile = profile;
-	strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
+	strscpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
 	devfreq->previous_freq = profile->initial_freq;
 	devfreq->last_status.current_frequency = profile->initial_freq;
 	devfreq->data = data;
-- 
2.24.0


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

* Re: [PATCH RE-SEND v1] PM / devfreq: Replace strncpy with strscpy
  2020-02-27 17:08 [PATCH RE-SEND v1] PM / devfreq: Replace strncpy with strscpy Dmitry Osipenko
@ 2020-04-17 14:04 ` Dmitry Osipenko
  2020-05-07  0:02   ` Chanwoo Choi
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Osipenko @ 2020-04-17 14:04 UTC (permalink / raw)
  To: MyungJoo Ham, Kyungmin Park, Chanwoo Choi; +Cc: linux-pm, linux-kernel

27.02.2020 20:08, Dmitry Osipenko пишет:
> GCC produces this warning when kernel compiled using `make W=1`:
> 
>   warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
>   772 |  strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
> 
> The strncpy doesn't take care of NULL-termination of the destination
> buffer, while the strscpy does.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/devfreq/devfreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 8494c5f05a73..2011f64bfa3a 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -769,7 +769,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
>  	devfreq->dev.release = devfreq_dev_release;
>  	INIT_LIST_HEAD(&devfreq->node);
>  	devfreq->profile = profile;
> -	strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
> +	strscpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
>  	devfreq->previous_freq = profile->initial_freq;
>  	devfreq->last_status.current_frequency = profile->initial_freq;
>  	devfreq->data = data;
> 

Hello Chanwoo,

Do you have any objections to this patch?

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

* Re: [PATCH RE-SEND v1] PM / devfreq: Replace strncpy with strscpy
  2020-04-17 14:04 ` Dmitry Osipenko
@ 2020-05-07  0:02   ` Chanwoo Choi
  2020-05-07  1:00     ` Dmitry Osipenko
  0 siblings, 1 reply; 4+ messages in thread
From: Chanwoo Choi @ 2020-05-07  0:02 UTC (permalink / raw)
  To: Dmitry Osipenko, MyungJoo Ham, Kyungmin Park; +Cc: linux-pm, linux-kernel

Hi Dmitry,

On 4/17/20 11:04 PM, Dmitry Osipenko wrote:
> 27.02.2020 20:08, Dmitry Osipenko пишет:
>> GCC produces this warning when kernel compiled using `make W=1`:
>>
>>   warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
>>   772 |  strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
>>
>> The strncpy doesn't take care of NULL-termination of the destination
>> buffer, while the strscpy does.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/devfreq/devfreq.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>> index 8494c5f05a73..2011f64bfa3a 100644
>> --- a/drivers/devfreq/devfreq.c
>> +++ b/drivers/devfreq/devfreq.c
>> @@ -769,7 +769,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
>>  	devfreq->dev.release = devfreq_dev_release;
>>  	INIT_LIST_HEAD(&devfreq->node);
>>  	devfreq->profile = profile;
>> -	strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
>> +	strscpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
>>  	devfreq->previous_freq = profile->initial_freq;
>>  	devfreq->last_status.current_frequency = profile->initial_freq;
>>  	devfreq->data = data;
>>
> 
> Hello Chanwoo,
> 
> Do you have any objections to this patch?
> 

I'm sorry for late reply. I applied it for v5.8-rc1.
Thanks.


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

* Re: [PATCH RE-SEND v1] PM / devfreq: Replace strncpy with strscpy
  2020-05-07  0:02   ` Chanwoo Choi
@ 2020-05-07  1:00     ` Dmitry Osipenko
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Osipenko @ 2020-05-07  1:00 UTC (permalink / raw)
  To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park; +Cc: linux-pm, linux-kernel

07.05.2020 03:02, Chanwoo Choi пишет:
> Hi Dmitry,
> 
> On 4/17/20 11:04 PM, Dmitry Osipenko wrote:
>> 27.02.2020 20:08, Dmitry Osipenko пишет:
>>> GCC produces this warning when kernel compiled using `make W=1`:
>>>
>>>   warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
>>>   772 |  strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
>>>
>>> The strncpy doesn't take care of NULL-termination of the destination
>>> buffer, while the strscpy does.
>>>
>>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>>> ---
>>>  drivers/devfreq/devfreq.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>> index 8494c5f05a73..2011f64bfa3a 100644
>>> --- a/drivers/devfreq/devfreq.c
>>> +++ b/drivers/devfreq/devfreq.c
>>> @@ -769,7 +769,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
>>>  	devfreq->dev.release = devfreq_dev_release;
>>>  	INIT_LIST_HEAD(&devfreq->node);
>>>  	devfreq->profile = profile;
>>> -	strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
>>> +	strscpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
>>>  	devfreq->previous_freq = profile->initial_freq;
>>>  	devfreq->last_status.current_frequency = profile->initial_freq;
>>>  	devfreq->data = data;
>>>
>>
>> Hello Chanwoo,
>>
>> Do you have any objections to this patch?
>>
> 
> I'm sorry for late reply. I applied it for v5.8-rc1.
> Thanks.

No problems, thank you :)

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

end of thread, other threads:[~2020-05-07  1:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-27 17:08 [PATCH RE-SEND v1] PM / devfreq: Replace strncpy with strscpy Dmitry Osipenko
2020-04-17 14:04 ` Dmitry Osipenko
2020-05-07  0:02   ` Chanwoo Choi
2020-05-07  1:00     ` Dmitry Osipenko

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).