diff mbox series

[rdma-next] RDMA/rxe: Properly check tasklet state

Message ID 1a6376525c40454282a14ab659de0b17b02fe523.1680113901.git.leon@kernel.org (mailing list archive)
State Changes Requested
Headers show
Series [rdma-next] RDMA/rxe: Properly check tasklet state | expand

Commit Message

Leon Romanovsky March 29, 2023, 6:18 p.m. UTC
From: Leon Romanovsky <leonro@nvidia.com>

Fix the following smatch error:

  drivers/infiniband/sw/rxe/rxe_task.c:24 __reserve_if_idle()
  warn: bitwise AND condition is false here

Fixes: d94671632572 ("RDMA/rxe: Rewrite rxe_task.c")
Reported-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/all/480b32b6-0f1c-4646-9ecc-e0760004cd24@kili.mountain
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/sw/rxe/rxe_task.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Bob Pearson March 29, 2023, 7:15 p.m. UTC | #1
On 3/29/23 13:18, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> Fix the following smatch error:
> 
>   drivers/infiniband/sw/rxe/rxe_task.c:24 __reserve_if_idle()
>   warn: bitwise AND condition is false here
> 
> Fixes: d94671632572 ("RDMA/rxe: Rewrite rxe_task.c")
> Reported-by: Dan Carpenter <error27@gmail.com>
> Link: https://lore.kernel.org/all/480b32b6-0f1c-4646-9ecc-e0760004cd24@kili.mountain
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_task.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_task.c b/drivers/infiniband/sw/rxe/rxe_task.c
> index fea9a517c8d9..48c89987137c 100644
> --- a/drivers/infiniband/sw/rxe/rxe_task.c
> +++ b/drivers/infiniband/sw/rxe/rxe_task.c
> @@ -21,7 +21,7 @@ static bool __reserve_if_idle(struct rxe_task *task)
>  {
>  	WARN_ON(rxe_read(task->qp) <= 0);
>  
> -	if (task->tasklet.state & TASKLET_STATE_SCHED)
> +	if (task->tasklet.state == TASKLET_STATE_SCHED)
>  		return false;
>  
>  	if (task->state == TASK_STATE_IDLE) {
> @@ -46,7 +46,7 @@ static bool __reserve_if_idle(struct rxe_task *task)
>   */
>  static bool __is_done(struct rxe_task *task)
>  {
> -	if (task->tasklet.state & TASKLET_STATE_SCHED)
> +	if (task->tasklet.state == TASKLET_STATE_SCHED)
>  		return false;
>  
>  	if (task->state == TASK_STATE_IDLE ||

Leon, This is not correct either. I am about to fix this. -- Bob
Leon Romanovsky March 29, 2023, 7:17 p.m. UTC | #2
On Wed, Mar 29, 2023 at 02:15:30PM -0500, Bob Pearson wrote:
> On 3/29/23 13:18, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@nvidia.com>
> > 
> > Fix the following smatch error:
> > 
> >   drivers/infiniband/sw/rxe/rxe_task.c:24 __reserve_if_idle()
> >   warn: bitwise AND condition is false here
> > 
> > Fixes: d94671632572 ("RDMA/rxe: Rewrite rxe_task.c")
> > Reported-by: Dan Carpenter <error27@gmail.com>
> > Link: https://lore.kernel.org/all/480b32b6-0f1c-4646-9ecc-e0760004cd24@kili.mountain
> > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> > ---
> >  drivers/infiniband/sw/rxe/rxe_task.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/infiniband/sw/rxe/rxe_task.c b/drivers/infiniband/sw/rxe/rxe_task.c
> > index fea9a517c8d9..48c89987137c 100644
> > --- a/drivers/infiniband/sw/rxe/rxe_task.c
> > +++ b/drivers/infiniband/sw/rxe/rxe_task.c
> > @@ -21,7 +21,7 @@ static bool __reserve_if_idle(struct rxe_task *task)
> >  {
> >  	WARN_ON(rxe_read(task->qp) <= 0);
> >  
> > -	if (task->tasklet.state & TASKLET_STATE_SCHED)
> > +	if (task->tasklet.state == TASKLET_STATE_SCHED)
> >  		return false;
> >  
> >  	if (task->state == TASK_STATE_IDLE) {
> > @@ -46,7 +46,7 @@ static bool __reserve_if_idle(struct rxe_task *task)
> >   */
> >  static bool __is_done(struct rxe_task *task)
> >  {
> > -	if (task->tasklet.state & TASKLET_STATE_SCHED)
> > +	if (task->tasklet.state == TASKLET_STATE_SCHED)
> >  		return false;
> >  
> >  	if (task->state == TASK_STATE_IDLE ||
> 
> Leon, This is not correct either. I am about to fix this. -- Bob

Sure, no problem.

Thanks
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_task.c b/drivers/infiniband/sw/rxe/rxe_task.c
index fea9a517c8d9..48c89987137c 100644
--- a/drivers/infiniband/sw/rxe/rxe_task.c
+++ b/drivers/infiniband/sw/rxe/rxe_task.c
@@ -21,7 +21,7 @@  static bool __reserve_if_idle(struct rxe_task *task)
 {
 	WARN_ON(rxe_read(task->qp) <= 0);
 
-	if (task->tasklet.state & TASKLET_STATE_SCHED)
+	if (task->tasklet.state == TASKLET_STATE_SCHED)
 		return false;
 
 	if (task->state == TASK_STATE_IDLE) {
@@ -46,7 +46,7 @@  static bool __reserve_if_idle(struct rxe_task *task)
  */
 static bool __is_done(struct rxe_task *task)
 {
-	if (task->tasklet.state & TASKLET_STATE_SCHED)
+	if (task->tasklet.state == TASKLET_STATE_SCHED)
 		return false;
 
 	if (task->state == TASK_STATE_IDLE ||