]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rpmsg: Use strscpy() instead of strscpy_pad()
authorThorsten Blum <thorsten.blum@linux.dev>
Tue, 29 Apr 2025 10:45:43 +0000 (12:45 +0200)
committerBjorn Andersson <andersson@kernel.org>
Sun, 21 Sep 2025 02:29:48 +0000 (21:29 -0500)
kzalloc() already zero-initializes the destination buffer, making
strscpy() sufficient for safely copying the name. The additional NUL-
padding performed by strscpy_pad() is unnecessary.

The size parameter is optional, and strscpy() automatically determines
the size of the destination buffer using sizeof() when the argument is
omitted. RPMSG_NAME_SIZE is equal to sizeof(rpdev->id.name) and can be
removed - remove it.

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20250429104543.66927-2-thorsten.blum@linux.dev
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/rpmsg/qcom_glink_native.c
drivers/rpmsg/qcom_smd.c

index a2f9d85c7156dca5794b740fae98f98661d10b11..820a6ca5b1d7a600e0b1d670ffe812f61b95ba4f 100644 (file)
@@ -1663,7 +1663,7 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid,
                }
 
                rpdev->ept = &channel->ept;
-               strscpy_pad(rpdev->id.name, name, RPMSG_NAME_SIZE);
+               strscpy(rpdev->id.name, name);
                rpdev->src = RPMSG_ADDR_ANY;
                rpdev->dst = RPMSG_ADDR_ANY;
                rpdev->ops = &glink_device_ops;
index 87c944d4b4f318183c0bdb9a3ce217bd472addd2..f0f12e7ad2a61922723c16e45738e93bd432c6c6 100644 (file)
@@ -1089,7 +1089,7 @@ static int qcom_smd_create_device(struct qcom_smd_channel *channel)
 
        /* Assign public information to the rpmsg_device */
        rpdev = &qsdev->rpdev;
-       strscpy_pad(rpdev->id.name, channel->name, RPMSG_NAME_SIZE);
+       strscpy(rpdev->id.name, channel->name);
        rpdev->src = RPMSG_ADDR_ANY;
        rpdev->dst = RPMSG_ADDR_ANY;