]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
caif: Replace memset(0) + strscpy() with strscpy_pad()
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 11 Aug 2025 09:34:40 +0000 (11:34 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 Aug 2025 21:08:56 +0000 (14:08 -0700)
Replace memset(0) followed by strscpy() with strscpy_pad() to improve
cfctrl_linkup_request(). This avoids zeroing the memory before copying
the string and ensures the destination buffer is only written to once,
simplifying the code and improving efficiency.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20250811093442.5075-2-thorsten.blum@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/caif/cfctrl.c

index 06b604cf9d58c0dd30008d8c34362e58ada60557..2aa1e7d46eb24424482b2aac51a7a39c09954404 100644 (file)
@@ -257,9 +257,7 @@ int cfctrl_linkup_request(struct cflayer *layer,
                cfpkt_add_body(pkt, &tmp16, 2);
                tmp16 = cpu_to_le16(param->u.utility.fifosize_bufs);
                cfpkt_add_body(pkt, &tmp16, 2);
-               memset(utility_name, 0, sizeof(utility_name));
-               strscpy(utility_name, param->u.utility.name,
-                       UTILITY_NAME_LENGTH);
+               strscpy_pad(utility_name, param->u.utility.name);
                cfpkt_add_body(pkt, utility_name, UTILITY_NAME_LENGTH);
                tmp8 = param->u.utility.paramlen;
                cfpkt_add_body(pkt, &tmp8, 1);