From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] IB/core: type promotion bug in rdma_rw_init_one_mr()
Date: Wed, 04 Jul 2018 10:48:31 +0000 [thread overview]
Message-ID: <20180704104831.pf2addlgbl3dzyvm@mwanda> (raw)
In-Reply-To: <20180704093211.o62tr44m3ugxxhjh@kili.mountain>
On Wed, Jul 04, 2018 at 12:41:53PM +0200, Walter Harms wrote:
>
> Am 04.07.2018 11:32, schrieb Dan Carpenter:
> > "nents" is an unsigned int, so if ib_map_mr_sg() returns a negative
> > error code then it's type promoted to a high unsigned int which is
> > treated as success.
> >
> > Fixes: a060b5629ab0 ("IB/core: generic RDMA READ/WRITE API")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c
> > index c8963e91f92a..3ee0adfb45e9 100644
> > --- a/drivers/infiniband/core/rw.c
> > +++ b/drivers/infiniband/core/rw.c
> > @@ -87,7 +87,7 @@ static int rdma_rw_init_one_mr(struct ib_qp *qp, u8
> > port_num,
> > }
> >
> > ret = ib_map_mr_sg(reg->mr, sg, nents, &offset, PAGE_SIZE);
> > - if (ret < nents) {
> > + if (ret < 0 || ret < nents) {
> > ib_mr_pool_put(qp, &qp->rdma_mrs, reg->mr);
> > return -EINVAL;
> > }
>
> I do not understand the error here.
>
> ib_map_mr_sg() obviously knows about nents and returns an invalid value ?
> Or is that a special case here ?
>
ib_map_mr_sg() can return -ENOMEM, -EINVAL, other error codes or a
positive number <= to nents. If it returns -ENOMEM then that's type
promoted to a high positive value (more than nents for sure) and treated
as success.
regards,
dan carpenter
next prev parent reply other threads:[~2018-07-04 10:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 9:32 [PATCH] IB/core: type promotion bug in rdma_rw_init_one_mr() Dan Carpenter
2018-07-04 10:41 ` Walter Harms
2018-07-04 10:48 ` Dan Carpenter [this message]
2018-07-04 14:49 ` Jason Gunthorpe
2018-07-04 16:27 ` Leon Romanovsky
2018-07-04 17:01 ` Dan Carpenter
2018-07-04 17:07 ` Dan Carpenter
2018-07-04 18:05 ` Jason Gunthorpe
2018-07-04 18:05 ` Jason Gunthorpe
2018-07-08 15:07 ` Christoph Hellwig
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=20180704104831.pf2addlgbl3dzyvm@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@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