]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/bnxt_re: Call strscpy() with correct size argument
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 1 Sep 2025 15:00:39 +0000 (17:00 +0200)
committerLeon Romanovsky <leon@kernel.org>
Thu, 11 Sep 2025 06:18:35 +0000 (02:18 -0400)
In bnxt_re_register_ib(), strscpy() is called with the length of the
source string rather than the size of the destination buffer.

This is fine as long as the destination buffer is larger than the source
string, but we should still use the destination buffer size instead to
call strscpy() as intended. And since 'node_desc' has a fixed size, we
can safely omit the size argument and let strscpy() infer it using
sizeof().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20250901150038.227036-2-thorsten.blum@linux.dev
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/bnxt_re/main.c

index f872211717fd307098a2924f0264c723b5b6cec6..e5a6f36e165605c954fbf26528ecd18abff5267e 100644 (file)
@@ -1383,8 +1383,7 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev)
 
        /* ib device init */
        ibdev->node_type = RDMA_NODE_IB_CA;
-       strscpy(ibdev->node_desc, BNXT_RE_DESC " HCA",
-               strlen(BNXT_RE_DESC) + 5);
+       strscpy(ibdev->node_desc, BNXT_RE_DESC " HCA");
        ibdev->phys_port_cnt = 1;
 
        addrconf_addr_eui48((u8 *)&ibdev->node_guid, rdev->netdev->dev_addr);