Re: [patch] infiniband: cxgb3: fix signed bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dan Carpenter wrote:
"num_wrs" should be signed so that the "if (num_wrs <= 0)" checks work.

Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>

diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c
index ae47bfd..e90fb2d 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_qp.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c
@@ -357,7 +357,7 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	struct iwch_qp *qhp;
 	u32 idx;
 	union t3_wr *wqe;
-	u32 num_wrs;
+	int num_wrs;
 	unsigned long flag;
 	struct t3_swsq *sqp;
 	int wr_cnt = 1;
@@ -535,7 +535,7 @@ int iwch_bind_mw(struct ib_qp *qp,
 	union t3_wr *wqe;
 	u32 pbl_addr;
 	u8 page_size;
-	u32 num_wrs;
+	int num_wrs;
 	unsigned long flag;
 	struct ib_sge sgl;
 	int err=0;
@@ -554,7 +554,7 @@ int iwch_bind_mw(struct ib_qp *qp,
 	}
 	num_wrs = Q_FREECNT(qhp->wq.sq_rptr, qhp->wq.sq_wptr,
 			    qhp->wq.sq_size_log2);
-	if ((num_wrs) <= 0) {
+	if (num_wrs <= 0) {
 		spin_unlock_irqrestore(&qhp->lock, flag);
 		return -ENOMEM;
 	}


The macro Q_FREECNT() must never return <0 or things are badly broken, so this patch should really leave num_wrs as unsigned and just check for num_wrs == 0.

Steve.

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux