mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Jang Ingyu <ingyujang25@korea.ac.kr>
Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] infiniband/core: Fix logic error in ib_get_gids_from_rdma_hdr()
Date: Sun, 21 Dec 2025 11:30:38 +0200	[thread overview]
Message-ID: <20251221093038.GG13030@unreal> (raw)
In-Reply-To: <20251221092418.GF13030@unreal>

On Sun, Dec 21, 2025 at 11:24:18AM +0200, Leon Romanovsky wrote:
> On Fri, Dec 19, 2025 at 01:15:08PM +0900, Jang Ingyu wrote:
> > Fix missing comparison operator for RDMA_NETWORK_ROCE_V1 in the
> > conditional statement. The constant was used directly instead of
> > being compared with net_type, causing the condition to always
> > evaluate to true.
> 
> In current code, it doesn't matter as network type can be one of four
> possible values, and this "else if" will be always true anyway.
> 
> I changed your patch to this and added Fixes line:
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index ee390928511ae..256f81c5803ff 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -737,14 +737,11 @@ int ib_get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr,
>                 ipv6_addr_set_v4mapped(dst_saddr,
>                                        (struct in6_addr *)dgid);
>                 return 0;
> -       } else if (net_type == RDMA_NETWORK_IPV6 ||
> -                  net_type == RDMA_NETWORK_IB || net_type == RDMA_NETWORK_ROCE_V1) {
> -               *dgid = hdr->ibgrh.dgid;
> -               *sgid = hdr->ibgrh.sgid;
> -               return 0;
> -       } else {
> -               return -EINVAL;
>         }
> +
> +       *dgid = hdr->ibgrh.dgid;
> +       *sgid = hdr->ibgrh.sgid;
> +       return 0;
>  }
>  EXPORT_SYMBOL(ib_get_gids_from_rdma_hdr);

After some additional consideration, I'll keep your patch as is.

My change is technically correct, but it's risky since some drivers  
use non‑conformant values.

Thanks.

> 
> > 
> > Signed-off-by: Jang Ingyu <ingyujang25@korea.ac.kr>
> > ---
> >  drivers/infiniband/core/verbs.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> > index 11b1a194d..ee3909285 100644
> > --- a/drivers/infiniband/core/verbs.c
> > +++ b/drivers/infiniband/core/verbs.c
> > @@ -738,7 +738,7 @@ int ib_get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr,
> >  				       (struct in6_addr *)dgid);
> >  		return 0;
> >  	} else if (net_type == RDMA_NETWORK_IPV6 ||
> > -		   net_type == RDMA_NETWORK_IB || RDMA_NETWORK_ROCE_V1) {
> > +		   net_type == RDMA_NETWORK_IB || net_type == RDMA_NETWORK_ROCE_V1) {
> >  		*dgid = hdr->ibgrh.dgid;
> >  		*sgid = hdr->ibgrh.sgid;
> >  		return 0;
> > -- 
> > 2.34.1
> > 
> > 
> 

  reply	other threads:[~2025-12-21  9:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-19  4:15 Jang Ingyu
2025-12-21  9:24 ` Leon Romanovsky
2025-12-21  9:30   ` Leon Romanovsky [this message]
2026-01-06  0:55     ` Jason Gunthorpe
2025-12-21  9:31 ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251221093038.GG13030@unreal \
    --to=leon@kernel.org \
    --cc=ingyujang25@korea.ac.kr \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®