Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/ucaps: Avoid format-security warning

Passing a non-literal format string to dev_set_name causes a warning:

drivers/infiniband/core/ucaps.c:173:33: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
173 | ret = dev_set_name(&ucap->dev, ucap_names[type]);
| ^~~~~~~~~~~~~~~~
drivers/infiniband/core/ucaps.c:173:33: note: treat the string as an argument to avoid this
173 | ret = dev_set_name(&ucap->dev, ucap_names[type]);
| ^
| "%s",

Turn the name into the %s argument as suggested by gcc.

Fixes: 61e51682816d ("RDMA/uverbs: Introduce UCAP (User CAPabilities) API")
Link: https://patch.msgid.link/r/20250314155721.264083-1-arnd@kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Arnd Bergmann and committed by
Jason Gunthorpe
62dd71e6 6b395d31

+1 -1
+1 -1
drivers/infiniband/core/ucaps.c
··· 170 170 ucap->dev.class = &ucaps_class; 171 171 ucap->dev.devt = MKDEV(MAJOR(ucaps_base_dev), type); 172 172 ucap->dev.release = ucap_dev_release; 173 - ret = dev_set_name(&ucap->dev, ucap_names[type]); 173 + ret = dev_set_name(&ucap->dev, "%s", ucap_names[type]); 174 174 if (ret) 175 175 goto err_device; 176 176