Re: [PATCH] inifiniband: ucaps: avoid format-security warning
From: Jason Gunthorpe
Date: Mon Apr 07 2025 - 14:00:40 EST
On Fri, Mar 14, 2025 at 04:57:15PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> Passing a non-constant 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 thet %s argument as suggested by gcc.
>
> Fixes: 61e51682816d ("RDMA/uverbs: Introduce UCAP (User CAPabilities) API")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> Reviewed-by: Zhu Yanjun <yanjun.zhu@xxxxxxxxx>
> Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> ---
> drivers/infiniband/core/ucaps.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to for-rc, thanks
Jason