Skip to content

Commit

Permalink
PM / devfreq: Replace strncpy with strscpy
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
  • Loading branch information
Dmitry Osipenko authored and Chanwoo Choi committed May 28, 2020
1 parent 0235521 commit a316b5c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/devfreq/devfreq.c
Original file line number Diff line number Diff line change
@@ -768,7 +768,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;

0 comments on commit a316b5c

Please sign in to comment.