* [PATCH] cxl: Fix wrong comparison in cxl_adapter_context_get()
@ 2018-07-04 15:28 Vaibhav Jain
2018-07-05 1:51 ` Andrew Donnellan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Vaibhav Jain @ 2018-07-04 15:28 UTC (permalink / raw)
To: linuxppc-dev, Frederic Barrat, Andrew Donnellan, Dan Carpenter
Cc: Vaibhav Jain, Christophe Lombard, Philippe Bergheaud,
Alastair D'Silva, stable
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
Cc: stable@vger.kernel.org
Fixes: 70b565bbdb91 ("cxl: Prevent adapter reset if an active context exists")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
drivers/misc/cxl/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c
index c1ba0d42cbc8..e0f29b8a872d 100644
--- a/drivers/misc/cxl/main.c
+++ b/drivers/misc/cxl/main.c
@@ -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)
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cxl: Fix wrong comparison in cxl_adapter_context_get()
2018-07-04 15:28 [PATCH] cxl: Fix wrong comparison in cxl_adapter_context_get() Vaibhav Jain
@ 2018-07-05 1:51 ` Andrew Donnellan
2018-07-05 7:29 ` Frederic Barrat
2018-07-23 15:11 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Donnellan @ 2018-07-05 1:51 UTC (permalink / raw)
To: Vaibhav Jain, linuxppc-dev, Frederic Barrat, Dan Carpenter
Cc: Christophe Lombard, Philippe Bergheaud, Alastair D'Silva, stable
On 05/07/18 01:28, Vaibhav Jain wrote:
> 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
>
> Cc: stable@vger.kernel.org
> Fixes: 70b565bbdb91 ("cxl: Prevent adapter reset if an active context exists")
> 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>
--
Andrew Donnellan OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com IBM Australia Limited
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cxl: Fix wrong comparison in cxl_adapter_context_get()
2018-07-04 15:28 [PATCH] cxl: Fix wrong comparison in cxl_adapter_context_get() Vaibhav Jain
2018-07-05 1:51 ` Andrew Donnellan
@ 2018-07-05 7:29 ` Frederic Barrat
2018-07-23 15:11 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Frederic Barrat @ 2018-07-05 7:29 UTC (permalink / raw)
To: Vaibhav Jain, linuxppc-dev, Andrew Donnellan, Dan Carpenter
Cc: Christophe Lombard, Philippe Bergheaud, Alastair D'Silva, stable
Le 04/07/2018 à 17:28, Vaibhav Jain a écrit :
> 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
>
> Cc: stable@vger.kernel.org
> Fixes: 70b565bbdb91 ("cxl: Prevent adapter reset if an active context exists")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> ---
Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
> drivers/misc/cxl/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c
> index c1ba0d42cbc8..e0f29b8a872d 100644
> --- a/drivers/misc/cxl/main.c
> +++ b/drivers/misc/cxl/main.c
> @@ -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)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: cxl: Fix wrong comparison in cxl_adapter_context_get()
2018-07-04 15:28 [PATCH] cxl: Fix wrong comparison in cxl_adapter_context_get() Vaibhav Jain
2018-07-05 1:51 ` Andrew Donnellan
2018-07-05 7:29 ` Frederic Barrat
@ 2018-07-23 15:11 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2018-07-23 15:11 UTC (permalink / raw)
To: Vaibhav Jain, linuxppc-dev, Frederic Barrat, Andrew Donnellan,
Dan Carpenter
Cc: Philippe Bergheaud, Vaibhav Jain, Alastair D'Silva,
Christophe Lombard, stable
On Wed, 2018-07-04 at 15:28:33 UTC, Vaibhav Jain wrote:
> 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
>
> Cc: stable@vger.kernel.org
> Fixes: 70b565bbdb91 ("cxl: Prevent adapter reset if an active context exists")
> 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>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/ef6cb5f1a048fdf91ccee6d63d2bfa
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-23 16:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 15:28 [PATCH] cxl: Fix wrong comparison in cxl_adapter_context_get() Vaibhav Jain
2018-07-05 1:51 ` Andrew Donnellan
2018-07-05 7:29 ` Frederic Barrat
2018-07-23 15:11 ` Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.