RDMA/srp: Avoid reading uninitialized has_port on srp_parse_in() failure
Subsystems (2)
PATCH 1/1 RDMA/srp: Avoid reading uninitialized has_port on srp_parse_in() failure
srp_parse_in() returns -ENOMEM without initializing *has_port if kstrdup() fails. Only check has_port when srp_parse_in() succeeds.
---
found by smatch:
- drivers/infiniband/ulp/srp/ib_srp.c:3502 srp_parse_options() error: uninitialized symbol 'has_port'.
drivers/infiniband/ulp/srp/ib_srp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/srp/ib_srp.c +1 -1
@@ -3499,7 +3499,7 @@ static int srp_parse_options(struct net *net, const char *buf, } ret =srp_parse_in (net, &target->rdma_cm.dst.ss, p, &has_port); -if (!has_port) +if (ret ==0 && !has_port) ret = -EINVAL ;if (ret <0 ) {pr_warn ("bad dest parameter '%s'\n" , p);
Signature · 1 line
2.53.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 5 lines
srp_parse_in()returns-ENOMEMwithout initializing*has_portifkstrdup()fails. Only checkhas_portwhensrp_parse_in()succeeds.Fixes bcef5b721568 ("RDMA/srp: Accept again source addresses that do not have a port number")Signed-off-by Serhat Kumral <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 17 lines · Serhat Kumral
srp_parse_in()returns-ENOMEMwithout initializing*has_portifkstrdup()fails. Only checkhas_portwhensrp_parse_in()succeeds.Fixes bcef5b721568 ("RDMA/srp: Accept again source addresses that do not have a port number")Signed-off-by Serhat Kumral <[email protected]>---
found by smatch:
-drivers/infiniband/ulp/srp/ib_srp.c:3502srp_parse_options()error: uninitialized symbol 'has_port'.drivers/infiniband/ulp/srp/ib_srp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/ulp/srp/ib_srp.c +0
-0
drivers/infiniband/ulp/srp/ib_srp.c static int srp_parse_options(struct net *net, const char *buf, · line 3505
Quoted 8 lines
drivers/infiniband/ulp/srp/ib_srp.c +1
-1@@ -3499,7 +3499,7 @@ static int srp_parse_options(struct net *net, const char *buf, } ret =srp_parse_in (net, &target->rdma_cm.dst.ss, p, &has_port); -if (!has_port) +if (ret ==0 && !has_port) ret = -EINVAL ;if (ret <0 ) {pr_warn ("bad dest parameter '%s'\n" , p);
Leon Romanovsky
AppliedQuoted 2 lines · Serhat Kumral
srp_parse_in()returns-ENOMEMwithout initializing*has_portifkstrdup()fails. Only checkhas_portwhensrp_parse_in()succeeds.
Applied, thanks!
[1/1] RDMA/srp: Avoid reading uninitialized has_port on srp_parse_in() failure
https://git.kernel.org/rdma/rdma/c/4b8f20dc8d25f5
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>