Linux RDMA and InfiniBand development
 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:16 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ 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 related	[flat|nested] 4+ 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:16 ` sashiko-bot
  2026-10-16 21:23 ` Bart Van Assche
  2026-10-18 12:13 ` Leon Romanovsky
  2 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-10-16 21:16 UTC (permalink / raw)
  To: Serhat Kumral; +Cc: linux-rdma

> 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>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261016211509.12973-1-serhatkumral1@gmail.com?part=1


^ permalink raw reply	[flat|nested] 4+ 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:16 ` sashiko-bot
@ 2026-10-16 21:23 ` Bart Van Assche
  2026-10-18 12:13 ` Leon Romanovsky
  2 siblings, 0 replies; 4+ 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] 4+ 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:16 ` sashiko-bot
  2026-10-16 21:23 ` Bart Van Assche
@ 2026-10-18 12:13 ` Leon Romanovsky
  2 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2026-10-18 12:13 UTC (permalink / raw)
  To: Bart Van Assche, Jason Gunthorpe, Serhat Kumral; +Cc: linux-rdma, linux-kernel


On Sat, 17 Oct 2026 00:15:09 +0300, Serhat Kumral wrote:
> srp_parse_in() returns -ENOMEM without initializing *has_port if
> kstrdup() fails. Only check has_port when srp_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,
-- 
Leon Romanovsky <leon@kernel.org>


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

end of thread, other threads:[~2026-10-18 12:13 UTC | newest]

Thread overview: 4+ 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:16 ` sashiko-bot
2026-10-16 21:23 ` Bart Van Assche
2026-10-18 12:13 ` Leon Romanovsky

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