Skip to content

Commit f706cf9

Browse files
hormsNipaLocal
authored andcommitted
wwan: core: Pass string literal as format argument of dev_set_name()
Both gcc-14 and clang-18 report that passing a non-string literal as the format argument of dev_set_name() is potentially insecure. E.g. clang-18 says: drivers/net/wwan/wwan_core.c:442:34: warning: format string is not a string literal (potentially insecure) [-Wformat-security] 442 | return dev_set_name(&port->dev, buf); | ^~~ drivers/net/wwan/wwan_core.c:442:34: note: treat the string as an argument to avoid this 442 | return dev_set_name(&port->dev, buf); | ^ | "%s", It is always the case where the contents of mod 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. No functional change intended. Signed-off-by: Simon Horman <[email protected]> Acked-by: Sergey Ryazanov <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 15e2474 commit f706cf9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/wwan/wwan_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ static int __wwan_port_dev_assign_name(struct wwan_port *port, const char *fmt)
431431
return -ENFILE;
432432
}
433433

434-
return dev_set_name(&port->dev, buf);
434+
return dev_set_name(&port->dev, "%s", buf);
435435
}
436436

437437
struct wwan_port *wwan_create_port(struct device *parent,

0 commit comments

Comments
 (0)