Skip to contentSkip to conversation

media: platform: amd: avoid -Wformat-security warning

PATCH In review Arnd Bergmann 3 participants 3 messages May 8

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: platform: amd: avoid -Wformat-security warning

From: Arnd Bergmann <[email protected]>

The newly added kthread_run() call passes a string variable as an sprintf() style format, which gcc warns about when -Wformat-security is enabled:

drivers/media/platform/amd/isp4/isp4_subdev.c: In function 'isp4sd_start_resp_proc_threads':
include/linux/kthread.h:71:16: error: format not a string literal and no format arguments [-Werror=format-security]

   71 |         struct task_struct *__k                                            \
      |                ^~~~~~~~~~~

drivers/media/platform/amd/isp4/isp4_subdev.c:596:38: note: in expansion of macro 'kthread_run'
596 | thread_ctx->thread = kthread_run(isp4sd_fw_resp_thread,
| ^~~~~~~~~~~

Use an indirect "%s" format to do this safely, avoiding the warning.

Fixes 4e5e7a7ddb4a ("media: platform: amd: isp4 subdev and firmware loading handling added")

---
v2: avoid overly long line

---
 drivers/media/platform/amd/isp4/isp4_subdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/amd/isp4/isp4_subdev.c +1 -0
index 48deea79ce6c..427e9ba910bb 100644
@@ -595,6 +595,7 @@ static int isp4sd_start_resp_proc_threads(struct isp4_subdev *isp_subdev)
 
 		thread_ctx->thread = kthread_run(isp4sd_fw_resp_thread,
 						 &isp_subdev->isp_resp_para[i],
+						 "%s",
 						 isp4sd_thread_name[i]);
 		if (IS_ERR(thread_ctx->thread)) {
 			dev_err(dev, "create thread [%d] fail\n", i);
Signature · 1 line
2.39.5
Reviewed-by Pratap Nirujogi on v2 1/1
#1 lore raw
Quoted 18 lines · Arnd Bergmann

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

From: Arnd Bergmann <[email protected]>

The newly added kthread_run() call passes a string variable as an sprintf() style format, which gcc warns about when -Wformat-security is enabled:

drivers/media/platform/amd/isp4/isp4_subdev.c: In function 'isp4sd_start_resp_proc_threads':
include/linux/kthread.h:71:16: error: format not a string literal and no format arguments [-Werror=format-security]

    71 |         struct task_struct *__k                                            \
       |                ^~~~~~~~~~~

drivers/media/platform/amd/isp4/isp4_subdev.c:596:38: note: in expansion of macro 'kthread_run'
596 | thread_ctx->thread = kthread_run(isp4sd_fw_resp_thread,
| ^~~~~~~~~~~

Quoted 5 lines

Use an indirect "%s" format to do this safely, avoiding the warning.

Fixes 4e5e7a7ddb4a ("media: platform: amd: isp4 subdev and firmware loading handling added")

Thanks,
Pratap

Quoted 21 lines

---
v2: avoid overly long line

---
  drivers/media/platform/amd/isp4/isp4_subdev.c | 1 +
  1 file changed, 1 insertion(+)
drivers/media/platform/amd/isp4/isp4_subdev.c +1 -1
index 48deea79ce6c..427e9ba910bb 100644
@@ -595,6 +595,7 @@ static int isp4sd_start_resp_proc_threads(struct isp4_subdev *isp_subdev)
 
                 thread_ctx->thread = kthread_run(isp4sd_fw_resp_thread,
                                                  &isp_subdev->isp_resp_para[i],
+                                                "%s",
                                                  isp4sd_thread_name[i]);
                 if (IS_ERR(thread_ctx->thread)) {
                         dev_err(dev, "create thread [%d] fail\n", i);
--

2.39.5

#2 lore raw
In reply to Arnd Bergmann
Quoted 29 lines · On Fri, 8 May 2026 14:43:49 +0200 Arnd Bergmann <[email protected]> wrote:

From: Arnd Bergmann <[email protected]>

The newly added kthread_run() call passes a string variable as an sprintf() style format, which gcc warns about when -Wformat-security is enabled:

drivers/media/platform/amd/isp4/isp4_subdev.c: In function 'isp4sd_start_resp_proc_threads':
include/linux/kthread.h:71:16: error: format not a string literal and no format arguments [-Werror=format-security]

   71 |         struct task_struct *__k                                            \
      |                ^~~~~~~~~~~

drivers/media/platform/amd/isp4/isp4_subdev.c:596:38: note: in expansion of macro 'kthread_run'
596 | thread_ctx->thread = kthread_run(isp4sd_fw_resp_thread,
| ^~~~~~~~~~~

Use an indirect "%s" format to do this safely, avoiding the warning.

Fixes 4e5e7a7ddb4a ("media: platform: amd: isp4 subdev and firmware loading handling added")

---
v2: avoid overly long line

---
 drivers/media/platform/amd/isp4/isp4_subdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/amd/isp4/isp4_subdev.c +0 -0
index 48deea79ce6c..427e9ba910bb 100644

drivers/media/platform/amd/isp4/isp4_subdev.c static int isp4sd_start_resp_proc_threads(struct isp4_subdev *isp_subdev) · line 599

Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_subdev.c +1 -0
@@ -595,6 +595,7 @@ static int isp4sd_start_resp_proc_threads(struct isp4_subdev *isp_subdev)
 
 		thread_ctx->thread = kthread_run(isp4sd_fw_resp_thread,
 						 &isp_subdev->isp_resp_para[i],
+						 "%s",
 						 isp4sd_thread_name[i]);

I don't think the line break is needed.
I always prefer a line break between the format and arguments when the whole lot doesn't fit on one line; but here it fits.

-- David

Quoted 2 lines
drivers/media/platform/amd/isp4/isp4_subdev.c +0 -0
 		if (IS_ERR(thread_ctx->thread)) {
 			dev_err(dev, "create thread [%d] fail\n", i);