Skip to content

Commit

Permalink
cxl: Fix wrong comparison in cxl_adapter_context_get()
Browse files Browse the repository at this point in the history
commit ef6cb5f upstream.

Function atomic_inc_unless_negative() returns a bool to indicate
success/failure. However cxl_adapter_context_get() wrongly compares
the return value against '>=0' which will always be true. The patch
fixes this comparison to '==0' there by also fixing this compile time
warning:

	drivers/misc/cxl/main.c:290 cxl_adapter_context_get()
	warn: 'atomic_inc_unless_negative(&adapter->contexts_num)' is unsigned

Fixes: 70b565b ("cxl: Prevent adapter reset if an active context exists")
Cc: [email protected] # v4.9+
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Vaibhav Jain <[email protected]>
Acked-by: Andrew Donnellan <[email protected]>
Acked-by: Frederic Barrat <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
vaibhav92 authored and gregkh committed Sep 9, 2018
1 parent f8700e0 commit 6f329f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/misc/cxl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ int cxl_adapter_context_get(struct cxl *adapter)
int rc;

rc = atomic_inc_unless_negative(&adapter->contexts_num);
return rc >= 0 ? 0 : -EBUSY;
return rc ? 0 : -EBUSY;
}

void cxl_adapter_context_put(struct cxl *adapter)
Expand Down

0 comments on commit 6f329f2

Please sign in to comment.