linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Barrat <fbarrat@linux.ibm.com>
To: Vaibhav Jain <vaibhav@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org,
	Andrew Donnellan <andrew.donnellan@au1.ibm.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Cc: Christophe Lombard <christophe_lombard@fr.ibm.com>,
	Philippe Bergheaud <philippe.bergheaud@fr.ibm.com>,
	"Alastair D'Silva" <alastair@linux.ibm.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] cxl: Fix wrong comparison in cxl_adapter_context_get()
Date: Thu, 5 Jul 2018 09:29:41 +0200	[thread overview]
Message-ID: <241bd81e-23bd-d590-b529-2cad223eeab7@linux.ibm.com> (raw)
In-Reply-To: <20180704152833.2288-1-vaibhav@linux.ibm.com>



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)
> 

  parent reply	other threads:[~2018-07-05  7:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2018-07-23 15:11 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=241bd81e-23bd-d590-b529-2cad223eeab7@linux.ibm.com \
    --to=fbarrat@linux.ibm.com \
    --cc=alastair@linux.ibm.com \
    --cc=andrew.donnellan@au1.ibm.com \
    --cc=christophe_lombard@fr.ibm.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=philippe.bergheaud@fr.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=vaibhav@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).