infiniband: cxgb3: fix signed bug
Subsystems (2)
PATCH 1/1 infiniband: cxgb3: fix signed bug
"num_wrs" should be signed so that the "if (num_wrs <= 0)" checks work.
drivers/infiniband/hw/cxgb3/iwch_qp.c +3 -3
@@ -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 ; }
Quoted 28 lines · Dan Carpenter
"
num_wrs" should be signed so that the "if (num_wrs<= 0)" checks work.Signed-off-by Dan Carpenter <[email protected]>drivers/infiniband/hw/cxgb3/iwch_qp.c +2
-2@@ -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 ;
drivers/infiniband/hw/cxgb3/iwch_qp.c int iwch_bind_mw(struct ib_qp *qp, · line 560
Quoted 8 lines
drivers/infiniband/hw/cxgb3/iwch_qp.c +1
-1@@ -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.
A message that is not in the archive (sent off-list or not yet received): 4C446509.3010400-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org
PATCH v2 1/1 infiniband: cxgb3: clean up signed check
Q_FREECNT() returns the number of spaces free. This should never be a negative amount. Also the num_wrs is an unsigned int so it can never be less than zero.
---
In v1: I changed num_wrs to a signed int.
drivers/infiniband/hw/cxgb3/iwch_qp.c +2 -2
@@ -371,7 +371,7 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, } 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); err = -ENOMEM ; goto out;
@@ -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 ; }
Re: [patch v2] infiniband: cxgb3: clean up signed check
Quoted 35 lines · Dan Carpenter
Q_FREECNT()returns the number of spaces free. This should never be a negative amount. Also thenum_wrsis an unsigned int so it can never be less than zero.Signed-off-by Dan Carpenter <[email protected]>---
In v1: I changednum_wrsto a signed int.drivers/infiniband/hw/cxgb3/iwch_qp.c +2
-3@@ -371,7 +371,7 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, } 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); err = -ENOMEM ; goto out;@@ -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 ; } --To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Roland Dreier
AppliedRe: [patch v2] infiniband: cxgb3: clean up signed check
In reply to Dan Carpenterthanks, applied
Signature · 2 lines
Roland Dreier <[email protected]> || For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/index.html