Skip to content

Commit 875db86

Browse files
keesVudentz
authored andcommitted
Bluetooth: vhci: Avoid needless snprintf() calls
Avoid double-copying of string literals. Use a "const char *" for each string instead of copying from .rodata into stack and then into the skb. We can go directly from .rodata to the skb. This also works around a Clang bug (that has since been fixed[1]). Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Fixes: ab4e438 ("Bluetooth: Add vhci devcoredump support") Link: llvm/llvm-project@ea2e66a [1] Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Reviewed-by: Josh Poimboeuf <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent e2e49e2 commit 875db86

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/bluetooth/hci_vhci.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,18 @@ static void vhci_coredump(struct hci_dev *hdev)
289289

290290
static void vhci_coredump_hdr(struct hci_dev *hdev, struct sk_buff *skb)
291291
{
292-
char buf[80];
292+
const char *buf;
293293

294-
snprintf(buf, sizeof(buf), "Controller Name: vhci_ctrl\n");
294+
buf = "Controller Name: vhci_ctrl\n";
295295
skb_put_data(skb, buf, strlen(buf));
296296

297-
snprintf(buf, sizeof(buf), "Firmware Version: vhci_fw\n");
297+
buf = "Firmware Version: vhci_fw\n";
298298
skb_put_data(skb, buf, strlen(buf));
299299

300-
snprintf(buf, sizeof(buf), "Driver: vhci_drv\n");
300+
buf = "Driver: vhci_drv\n";
301301
skb_put_data(skb, buf, strlen(buf));
302302

303-
snprintf(buf, sizeof(buf), "Vendor: vhci\n");
303+
buf = "Vendor: vhci\n";
304304
skb_put_data(skb, buf, strlen(buf));
305305
}
306306

0 commit comments

Comments
 (0)