Commit 92218f10 authored by Simon Horman's avatar Simon Horman Committed by Jakub Kicinski
Browse files

octeontx2-af: Pass string literal as format argument of alloc_workqueue()



Recently I noticed that both gcc-14 and clang-18 report that passing
a non-string literal as the format argument of alloc_workqueue()
is potentially insecure.

E.g. clang-18 says:

.../rvu.c:2493:32: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
 2493 |         mw->mbox_wq = alloc_workqueue(name,
      |                                       ^~~~
.../rvu.c:2493:32: note: treat the string as an argument to avoid this
 2493 |         mw->mbox_wq = alloc_workqueue(name,
      |                                       ^
      |                                       "%s",

It is always the case where the contents of name is safe to pass as the
format argument. That is, in my understanding, it never contains any
format escape sequences.

But, it seems better to be safe than sorry. And, as a bonus, compiler
output becomes less verbose by addressing this issue as suggested by
clang-18.

Compile tested only by author.

Tested-by: default avatarGeetha sowjanya <gakula@marvell.com>
Signed-off-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240904-octeontx2-sparse-v2-1-14f2305fe4b2@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent cca0d69b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2479,9 +2479,9 @@ static int rvu_mbox_init(struct rvu *rvu, struct mbox_wq_info *mw,
		goto free_regions;
	}

	mw->mbox_wq = alloc_workqueue(name,
	mw->mbox_wq = alloc_workqueue("%s",
				      WQ_UNBOUND | WQ_HIGHPRI | WQ_MEM_RECLAIM,
				      num);
				      num, name);
	if (!mw->mbox_wq) {
		err = -ENOMEM;
		goto unmap_regions;