Skip to content

Commit ef6cb5f

Browse files
vaibhav92mpe
authored andcommitted
cxl: Fix wrong comparison in cxl_adapter_context_get()
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: stable@vger.kernel.org # v4.9+ Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com> Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 99c3ce3 commit ef6cb5f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎drivers/misc/cxl/main.c‎

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

284284
rc = atomic_inc_unless_negative(&adapter->contexts_num);
285-
return rc >= 0 ? 0 : -EBUSY;
285+
return rc ? 0 : -EBUSY;
286286
}
287287

288288
void cxl_adapter_context_put(struct cxl *adapter)

0 commit comments

Comments
 (0)