mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] RDMA/srp: Avoid reading uninitialized has_port on srp_parse_in() failure
@ 2026-10-16 21:15 Serhat Kumral
  2026-10-16 21:23 ` Bart Van Assche
  0 siblings, 1 reply; 2+ messages in thread
From: Serhat Kumral @ 2026-10-16 21:15 UTC (permalink / raw)
  To: Bart Van Assche, Jason Gunthorpe, Leon Romanovsky
  Cc: linux-rdma, linux-kernel, Serhat Kumral

srp_parse_in() returns -ENOMEM without initializing *has_port if
kstrdup() fails. Only check has_port when srp_parse_in() succeeds.

Fixes: bcef5b721568 ("RDMA/srp: Accept again source addresses that do not have a port number")
Signed-off-by: Serhat Kumral <serhatkumral1@gmail.com>
---
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(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 955f36efeebd..5811f02df980 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -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);
-- 
2.53.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] RDMA/srp: Avoid reading uninitialized has_port on srp_parse_in() failure
  2026-10-16 21:15 [PATCH] RDMA/srp: Avoid reading uninitialized has_port on srp_parse_in() failure Serhat Kumral
@ 2026-10-16 21:23 ` Bart Van Assche
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2026-10-16 21:23 UTC (permalink / raw)
  To: Serhat Kumral, Jason Gunthorpe, Leon Romanovsky; +Cc: linux-rdma, linux-kernel

On 10/16/26 2:15 PM, Serhat Kumral wrote:
> srp_parse_in() returns -ENOMEM without initializing *has_port if
> kstrdup() fails. Only check has_port when srp_parse_in() succeeds.
> 
> Fixes: bcef5b721568 ("RDMA/srp: Accept again source addresses that do not have a port number")
> Signed-off-by: Serhat Kumral <serhatkumral1@gmail.com>
> ---
> 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(-)
> 
> diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
> index 955f36efeebd..5811f02df980 100644
> --- a/drivers/infiniband/ulp/srp/ib_srp.c
> +++ b/drivers/infiniband/ulp/srp/ib_srp.c
> @@ -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);

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-16 21:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-16 21:15 [PATCH] RDMA/srp: Avoid reading uninitialized has_port on srp_parse_in() failure Serhat Kumral
2026-10-16 21:23 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®