Skip to content

Commit a316b5c

Browse files
digetxchanwoochoi
authored andcommitted
PM / devfreq: Replace strncpy with strscpy
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 <[email protected]> Signed-off-by: Chanwoo Choi <[email protected]>
1 parent 0235521 commit a316b5c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/devfreq/devfreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
768768
devfreq->dev.release = devfreq_dev_release;
769769
INIT_LIST_HEAD(&devfreq->node);
770770
devfreq->profile = profile;
771-
strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
771+
strscpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
772772
devfreq->previous_freq = profile->initial_freq;
773773
devfreq->last_status.current_frequency = profile->initial_freq;
774774
devfreq->data = data;

0 commit comments

Comments
 (0)