diff mbox series

[rdma-core,v2] providers/rxe: Replace '%' with '&' in check_qp_queue_full()

Message ID 20220121062222.2914007-1-yangx.jy@fujitsu.com (mailing list archive)
State Accepted
Delegated to: Leon Romanovsky
Headers show
Series [rdma-core,v2] providers/rxe: Replace '%' with '&' in check_qp_queue_full() | expand

Commit Message

Xiao Yang Jan. 21, 2022, 6:22 a.m. UTC
The expression "cons == ((qp->cur_index + 1) % q->index_mask)" doesn't
check the state of queue (full or empty) correctly.  For example:
If cons and qp->cur_index are 0 and q->index_mask is 1, the queue is actually
empty but check_qp_queue_full() reports full (ENOSPC).

Fixes: 1a894ca10105 ("Providers/rxe: Implement ibv_create_qp_ex verb")
Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
---
 providers/rxe/rxe_queue.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bob Pearson Jan. 21, 2022, 6:47 a.m. UTC | #1
On 1/21/22 00:22, Xiao Yang wrote:
> The expression "cons == ((qp->cur_index + 1) % q->index_mask)" doesn't
> check the state of queue (full or empty) correctly.  For example:
> If cons and qp->cur_index are 0 and q->index_mask is 1, the queue is actually
> empty but check_qp_queue_full() reports full (ENOSPC).
> 
> Fixes: 1a894ca10105 ("Providers/rxe: Implement ibv_create_qp_ex verb")
> Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
> ---
>  providers/rxe/rxe_queue.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/providers/rxe/rxe_queue.h b/providers/rxe/rxe_queue.h
> index 6de8140c..708e76ac 100644
> --- a/providers/rxe/rxe_queue.h
> +++ b/providers/rxe/rxe_queue.h
> @@ -205,7 +205,7 @@ static inline int check_qp_queue_full(struct rxe_qp *qp)
>  	if (qp->err)
>  		goto err;
>  
> -	if (cons == ((qp->cur_index + 1) % q->index_mask))
> +	if (cons == ((qp->cur_index + 1) & q->index_mask))
>  		qp->err = ENOSPC;
>  err:
>  	return qp->err;
> 
This is fine.

Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>
Leon Romanovsky Jan. 23, 2022, 11:04 a.m. UTC | #2
On Fri, Jan 21, 2022 at 02:22:22PM +0800, Xiao Yang wrote:
> The expression "cons == ((qp->cur_index + 1) % q->index_mask)" doesn't
> check the state of queue (full or empty) correctly.  For example:
> If cons and qp->cur_index are 0 and q->index_mask is 1, the queue is actually
> empty but check_qp_queue_full() reports full (ENOSPC).
> 
> Fixes: 1a894ca10105 ("Providers/rxe: Implement ibv_create_qp_ex verb")
> Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
> ---
>  providers/rxe/rxe_queue.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Thanks, applied.
diff mbox series

Patch

diff --git a/providers/rxe/rxe_queue.h b/providers/rxe/rxe_queue.h
index 6de8140c..708e76ac 100644
--- a/providers/rxe/rxe_queue.h
+++ b/providers/rxe/rxe_queue.h
@@ -205,7 +205,7 @@  static inline int check_qp_queue_full(struct rxe_qp *qp)
 	if (qp->err)
 		goto err;
 
-	if (cons == ((qp->cur_index + 1) % q->index_mask))
+	if (cons == ((qp->cur_index + 1) & q->index_mask))
 		qp->err = ENOSPC;
 err:
 	return qp->err;