Skip to content

Commit 241e620

Browse files
vaibhav92gregkh
authored andcommitted
cxl: Fix wrong comparison in cxl_adapter_context_get()
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]>
1 parent 1eb08e7 commit 241e620

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/misc/cxl/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ int cxl_adapter_context_get(struct cxl *adapter)
287287
int rc;
288288

289289
rc = atomic_inc_unless_negative(&adapter->contexts_num);
290-
return rc >= 0 ? 0 : -EBUSY;
290+
return rc ? 0 : -EBUSY;
291291
}
292292

293293
void cxl_adapter_context_put(struct cxl *adapter)

0 commit comments

Comments
 (0)