Skip to contentSkip to conversation

cxl: Fix wrong comparison in cxl_adapter_context_get()

PATCH Applied Vaibhav Jain 4 participants 4 messages Jul 4, 2018 – Jul 23, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/misc/cxl/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/cxl/main.c +1 -1
index c1ba0d42cbc8..e0f29b8a872d 100644
@@ -287,7 +287,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)
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Vaibhav Jain

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:

Quoted 7 lines
	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")
Signature · 2 lines
Andrew Donnellan              OzLabs, ADL Canberra
[email protected]  IBM Australia Limited
Acked-by on v1 1/1
#2 lore raw
In reply to Vaibhav Jain

Le 04/07/2018 à 17:28, Vaibhav Jain a écrit :

Quoted 6 lines

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:

Quoted 8 lines
	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")

---

Quoted 17 lines
  drivers/misc/cxl/main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/cxl/main.c +1 -1
index c1ba0d42cbc8..e0f29b8a872d 100644
@@ -287,7 +287,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)
#3 lore raw
In reply to Vaibhav Jain
Quoted 9 lines · Vaibhav Jain

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
Quoted 6 lines
Fixes 70b565bbdb91 ("cxl: Prevent adapter reset if an active context exists")

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/ef6cb5f1a048fdf91ccee6d63d2bfa

cheers