[PATCH] nvme: work around -Wformat-security warning

Nilay Shroff nilay at linux.ibm.com
Wed Sep 16 21:14:51 PDT 2026


On 9/16/26 5:14 PM, Arnd Bergmann wrote:
> From: Arnd Bergmann<arnd at arndb.de>
> 
> Passing a string variable into dev_set_name() causes a warning
> when building with -Wformat-security enabled:
> 
> drivers/nvme/host/core.c: In function 'nvme_cdev_add':
> drivers/nvme/host/core.c:3911:9: error: format not a string literal and no format arguments [-Werror=format-security]
>   3911 |         ret = dev_set_name(cdev_device, name);
> 
> Remove the temporary strings and let dev_set_name() do the
> same thing internally.
> 
> Fixes: 26acdaa357cd ("nvme: fix crash and memory leak during invalid cdev teardown")
> Signed-off-by: Arnd Bergmann<arnd at arndb.de>

The changes look good. However, I applied the patch and built
drivers/nvme/ with -Wformat-security, and I still see a couple of
additional warnings:

$ make M=drivers/nvme/ KCFLAGS="-Wformat-security"
make[1]: Entering directory '/home/nilay/Development/linux-x86/drivers/nvme'
[...]
host/sysfs.c: In function ‘cntrltype_show’:
host/sysfs.c:682:9: error: format not a string literal and no format arguments [-Werror=format-security]
   682 |         return sysfs_emit(buf, type[ctrl->cntrltype]);
       |         ^~~~~~
host/sysfs.c: In function ‘dctype_show’:
host/sysfs.c:699:9: error: format not a string literal and no format arguments [-Werror=format-security]
   699 |         return sysfs_emit(buf, type[ctrl->dctype]);
       |         ^~~~~~

I think that if we're fixing -Wformat-security warnings in the NVMe
driver, it would be useful to address above warnings as part of this
patch as well.

Thanks,
--Nilay



More information about the Linux-nvme mailing list