public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/core: type promotion bug in rdma_rw_init_one_mr()
@ 2018-07-04  9:32 Dan Carpenter
  2018-07-04 10:41 ` Walter Harms
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Dan Carpenter @ 2018-07-04  9:32 UTC (permalink / raw)
  To: kernel-janitors

"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;
 	}

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

end of thread, other threads:[~2018-07-08 15:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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