LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] ptp: drop redundant kasprintf() to create worker name
@ 2018-10-26 21:22 Rasmus Villemoes
2018-10-27 13:04 ` Richard Cochran
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2018-10-26 21:22 UTC (permalink / raw)
To: Richard Cochran; +Cc: Kees Cook, Rasmus Villemoes, netdev, linux-kernel
Building with -Wformat-nonliteral, gcc complains
drivers/ptp/ptp_clock.c: In function ‘ptp_clock_register’:
drivers/ptp/ptp_clock.c:239:26: warning: format not a string literal and no format arguments [-Wformat-nonliteral]
worker_name : info->name);
kthread_create_worker takes fmt+varargs to set the name of the
worker, and that happens with a vsnprintf() to a stack buffer (that is
then copied into task_comm). So there's no reason not to just pass
"ptp%d", ptp->index to kthread_create_worker() and avoid the
intermediate worker_name variable.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
drivers/ptp/ptp_clock.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index 7eacc1c4b3b1..5419a89d300e 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -232,12 +232,8 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
init_waitqueue_head(&ptp->tsev_wq);
if (ptp->info->do_aux_work) {
- char *worker_name = kasprintf(GFP_KERNEL, "ptp%d", ptp->index);
-
kthread_init_delayed_work(&ptp->aux_work, ptp_aux_kworker);
- ptp->kworker = kthread_create_worker(0, worker_name ?
- worker_name : info->name);
- kfree(worker_name);
+ ptp->kworker = kthread_create_worker(0, "ptp%d", ptp->index);
if (IS_ERR(ptp->kworker)) {
err = PTR_ERR(ptp->kworker);
pr_err("failed to create ptp aux_worker %d\n", err);
--
2.19.1.6.gbde171bbf5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ptp: drop redundant kasprintf() to create worker name
2018-10-26 21:22 [PATCH] ptp: drop redundant kasprintf() to create worker name Rasmus Villemoes
@ 2018-10-27 13:04 ` Richard Cochran
2018-10-28 16:05 ` Kees Cook
2018-10-29 2:20 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Richard Cochran @ 2018-10-27 13:04 UTC (permalink / raw)
To: Rasmus Villemoes; +Cc: Kees Cook, netdev, linux-kernel
On Fri, Oct 26, 2018 at 11:22:59PM +0200, Rasmus Villemoes wrote:
> Building with -Wformat-nonliteral, gcc complains
>
> drivers/ptp/ptp_clock.c: In function ‘ptp_clock_register’:
> drivers/ptp/ptp_clock.c:239:26: warning: format not a string literal and no format arguments [-Wformat-nonliteral]
> worker_name : info->name);
>
> kthread_create_worker takes fmt+varargs to set the name of the
> worker, and that happens with a vsnprintf() to a stack buffer (that is
> then copied into task_comm). So there's no reason not to just pass
> "ptp%d", ptp->index to kthread_create_worker() and avoid the
> intermediate worker_name variable.
Acked-by: Richard Cochran <richardcochran@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ptp: drop redundant kasprintf() to create worker name
2018-10-26 21:22 [PATCH] ptp: drop redundant kasprintf() to create worker name Rasmus Villemoes
2018-10-27 13:04 ` Richard Cochran
@ 2018-10-28 16:05 ` Kees Cook
2018-10-29 2:20 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2018-10-28 16:05 UTC (permalink / raw)
To: Rasmus Villemoes; +Cc: Richard Cochran, Network Development, LKML
On Fri, Oct 26, 2018 at 10:22 PM, Rasmus Villemoes
<linux@rasmusvillemoes.dk> wrote:
> Building with -Wformat-nonliteral, gcc complains
>
> drivers/ptp/ptp_clock.c: In function ‘ptp_clock_register’:
> drivers/ptp/ptp_clock.c:239:26: warning: format not a string literal and no format arguments [-Wformat-nonliteral]
> worker_name : info->name);
>
> kthread_create_worker takes fmt+varargs to set the name of the
> worker, and that happens with a vsnprintf() to a stack buffer (that is
> then copied into task_comm). So there's no reason not to just pass
> "ptp%d", ptp->index to kthread_create_worker() and avoid the
> intermediate worker_name variable.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> drivers/ptp/ptp_clock.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
> index 7eacc1c4b3b1..5419a89d300e 100644
> --- a/drivers/ptp/ptp_clock.c
> +++ b/drivers/ptp/ptp_clock.c
> @@ -232,12 +232,8 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
> init_waitqueue_head(&ptp->tsev_wq);
>
> if (ptp->info->do_aux_work) {
> - char *worker_name = kasprintf(GFP_KERNEL, "ptp%d", ptp->index);
> -
> kthread_init_delayed_work(&ptp->aux_work, ptp_aux_kworker);
> - ptp->kworker = kthread_create_worker(0, worker_name ?
> - worker_name : info->name);
> - kfree(worker_name);
> + ptp->kworker = kthread_create_worker(0, "ptp%d", ptp->index);
> if (IS_ERR(ptp->kworker)) {
> err = PTR_ERR(ptp->kworker);
> pr_err("failed to create ptp aux_worker %d\n", err);
> --
> 2.19.1.6.gbde171bbf5
>
--
Kees Cook
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ptp: drop redundant kasprintf() to create worker name
2018-10-26 21:22 [PATCH] ptp: drop redundant kasprintf() to create worker name Rasmus Villemoes
2018-10-27 13:04 ` Richard Cochran
2018-10-28 16:05 ` Kees Cook
@ 2018-10-29 2:20 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-10-29 2:20 UTC (permalink / raw)
To: linux; +Cc: richardcochran, keescook, netdev, linux-kernel
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Date: Fri, 26 Oct 2018 23:22:59 +0200
> Building with -Wformat-nonliteral, gcc complains
>
> drivers/ptp/ptp_clock.c: In function ‘ptp_clock_register’:
> drivers/ptp/ptp_clock.c:239:26: warning: format not a string literal and no format arguments [-Wformat-nonliteral]
> worker_name : info->name);
>
> kthread_create_worker takes fmt+varargs to set the name of the
> worker, and that happens with a vsnprintf() to a stack buffer (that is
> then copied into task_comm). So there's no reason not to just pass
> "ptp%d", ptp->index to kthread_create_worker() and avoid the
> intermediate worker_name variable.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-29 2:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-26 21:22 [PATCH] ptp: drop redundant kasprintf() to create worker name Rasmus Villemoes
2018-10-27 13:04 ` Richard Cochran
2018-10-28 16:05 ` Kees Cook
2018-10-29 2:20 ` David Miller
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).