mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 13:53:33 +00:00
RDMA/rtrs-clt: Check strnlen return len in sysfs mpath_policy_store()
strnlen() may return 0 (e.g. for "\0\n" string), it's better to
check the result of strnlen() before using 'len - 1' expression
for the 'buf' array index.
Detected using the static analysis tool - Svace.
Fixes: dc3b66a0ce
("RDMA/rtrs-clt: Add a minimum latency multipath policy")
Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
Link: https://lore.kernel.org/r/20240221113204.147478-1-aleksei.kodanev@bell-sw.com
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
14b526f55b
commit
7a7b7f575a
1 changed files with 1 additions and 1 deletions
|
@ -133,7 +133,7 @@ static ssize_t mpath_policy_store(struct device *dev,
|
||||||
|
|
||||||
/* distinguish "mi" and "min-latency" with length */
|
/* distinguish "mi" and "min-latency" with length */
|
||||||
len = strnlen(buf, NAME_MAX);
|
len = strnlen(buf, NAME_MAX);
|
||||||
if (buf[len - 1] == '\n')
|
if (len && buf[len - 1] == '\n')
|
||||||
len--;
|
len--;
|
||||||
|
|
||||||
if (!strncasecmp(buf, "round-robin", 11) ||
|
if (!strncasecmp(buf, "round-robin", 11) ||
|
||||||
|
|
Loading…
Reference in a new issue