summaryrefslogtreecommitdiffstats
path: root/drivers/misc/cxl
diff options
context:
space:
mode:
authorVaibhav Jain <vaibhav@linux.ibm.com>2018-07-04 17:28:33 +0200
committerMichael Ellerman <mpe@ellerman.id.au>2018-07-19 13:58:11 +0200
commitef6cb5f1a048fdf91ccee6d63d2bfa293338502d (patch)
tree8723504eb84b7bd7724dc77e3bf7381adb7b7d4c /drivers/misc/cxl
parentpowerpc/powernv/npu: Add a debugfs setting to change ATSD threshold (diff)
downloadlinux-ef6cb5f1a048fdf91ccee6d63d2bfa293338502d.tar.xz
linux-ef6cb5f1a048fdf91ccee6d63d2bfa293338502d.zip
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: 70b565bbdb91 ("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>
Diffstat (limited to 'drivers/misc/cxl')
-rw-r--r--drivers/misc/cxl/main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c
index 334223b802ee..f35406be465a 100644
--- a/drivers/misc/cxl/main.c
+++ b/drivers/misc/cxl/main.c
@@ -282,7 +282,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)