kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] infiniband: cxgb3: fix signed bug
@ 2010-07-17 10:29 Dan Carpenter
  2010-07-19 14:45 ` Steve Wise
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2010-07-17 10:29 UTC (permalink / raw)
  To: Steve Wise
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Frank Zago,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

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

Signed-off-by: Dan Carpenter <error27@gmail.com>

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

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

* Re: [patch] infiniband: cxgb3: fix signed bug
  2010-07-17 10:29 [patch] infiniband: cxgb3: fix signed bug Dan Carpenter
@ 2010-07-19 14:45 ` Steve Wise
       [not found]   ` <4C446509.3010400-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Steve Wise @ 2010-07-19 14:45 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Steve Wise, Roland Dreier, Sean Hefty, Hal Rosenstock, Frank Zago,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

Dan Carpenter wrote:
> "num_wrs" should be signed so that the "if (num_wrs <= 0)" checks work.
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
> 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.


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

* [patch v2] infiniband: cxgb3: clean up signed check
       [not found]   ` <4C446509.3010400-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
@ 2010-07-19 20:30     ` Dan Carpenter
  2010-07-19 22:17       ` Steve Wise
  2010-07-21 17:57       ` Roland Dreier
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2010-07-19 20:30 UTC (permalink / raw)
  To: Steve Wise
  Cc: Steve Wise, Roland Dreier, Sean Hefty, Hal Rosenstock, Frank Zago,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

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.

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
In v1: I changed num_wrs to a signed int.

diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c
index ae47bfd..6adc13f 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_qp.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c
@@ -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;
 	}

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

* Re: [patch v2] infiniband: cxgb3: clean up signed check
  2010-07-19 20:30     ` [patch v2] infiniband: cxgb3: clean up signed check Dan Carpenter
@ 2010-07-19 22:17       ` Steve Wise
  2010-07-21 17:57       ` Roland Dreier
  1 sibling, 0 replies; 5+ messages in thread
From: Steve Wise @ 2010-07-19 22:17 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Steve Wise, Roland Dreier, Sean Hefty, Hal Rosenstock, Frank Zago,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

Acked-by: Steve Wise <swise@opengridcomputing.com>

Dan Carpenter wrote:
> 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.
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> In v1: I changed num_wrs to a signed int.
>
> diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c
> index ae47bfd..6adc13f 100644
> --- a/drivers/infiniband/hw/cxgb3/iwch_qp.c
> +++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>   


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

* Re: [patch v2] infiniband: cxgb3: clean up signed check
  2010-07-19 20:30     ` [patch v2] infiniband: cxgb3: clean up signed check Dan Carpenter
  2010-07-19 22:17       ` Steve Wise
@ 2010-07-21 17:57       ` Roland Dreier
  1 sibling, 0 replies; 5+ messages in thread
From: Roland Dreier @ 2010-07-21 17:57 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Steve Wise, Steve Wise, Roland Dreier, Sean Hefty, Hal Rosenstock,
	Frank Zago, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

thanks, applied
-- 
Roland Dreier <rolandd@cisco.com> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html

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

end of thread, other threads:[~2010-07-21 17:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-17 10:29 [patch] infiniband: cxgb3: fix signed bug Dan Carpenter
2010-07-19 14:45 ` Steve Wise
     [not found]   ` <4C446509.3010400-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
2010-07-19 20:30     ` [patch v2] infiniband: cxgb3: clean up signed check Dan Carpenter
2010-07-19 22:17       ` Steve Wise
2010-07-21 17:57       ` Roland Dreier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).