[PATCH] media: platform: amd: avoid -Wformat-security warning

Arnd Bergmann posted 1 patch 1 month ago
There is a newer version of this series
drivers/media/platform/amd/isp4/isp4_subdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] media: platform: amd: avoid -Wformat-security warning
Posted by Arnd Bergmann 1 month ago
From: Arnd Bergmann <arnd@arndb.de>

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/media/platform/amd/isp4/isp4_subdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/amd/isp4/isp4_subdev.c b/drivers/media/platform/amd/isp4/isp4_subdev.c
index 48deea79ce6c..86680ec8730d 100644
--- a/drivers/media/platform/amd/isp4/isp4_subdev.c
+++ b/drivers/media/platform/amd/isp4/isp4_subdev.c
@@ -595,7 +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],
-						 isp4sd_thread_name[i]);
+						 "%s", isp4sd_thread_name[i]);
 		if (IS_ERR(thread_ctx->thread)) {
 			dev_err(dev, "create thread [%d] fail\n", i);
 			thread_ctx->thread = NULL;
-- 
2.39.5
Re: [PATCH] media: platform: amd: avoid -Wformat-security warning
Posted by Bin Du 1 month ago
Hi Arnd,


Thanks for the fix. I applied it on top of my current branch and 
verified that
it resolves the -Wformat-security warning in the ISP4 driver build here.


Tested-by: Bin Du <Bin.Du@amd.com>

On 5/8/2026 3:52 PM, Arnd Bergmann wrote:
> [You don't often get email from arnd@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/media/platform/amd/isp4/isp4_subdev.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/amd/isp4/isp4_subdev.c b/drivers/media/platform/amd/isp4/isp4_subdev.c
> index 48deea79ce6c..86680ec8730d 100644
> --- a/drivers/media/platform/amd/isp4/isp4_subdev.c
> +++ b/drivers/media/platform/amd/isp4/isp4_subdev.c
> @@ -595,7 +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],
> -                                                isp4sd_thread_name[i]);
> +                                                "%s", isp4sd_thread_name[i]);
>                  if (IS_ERR(thread_ctx->thread)) {
>                          dev_err(dev, "create thread [%d] fail\n", i);
>                          thread_ctx->thread = NULL;
> --
> 2.39.5
>