Return-Path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40494 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752165AbeGDP2z (ORCPT ); Wed, 4 Jul 2018 11:28:55 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w64FSj2l021486 for ; Wed, 4 Jul 2018 11:28:54 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2k0xdt6h1u-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 04 Jul 2018 11:28:54 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Jul 2018 16:28:52 +0100 From: Vaibhav Jain To: linuxppc-dev@lists.ozlabs.org, Frederic Barrat , Andrew Donnellan , Dan Carpenter Cc: Vaibhav Jain , Christophe Lombard , Philippe Bergheaud , "Alastair D'Silva" , stable@vger.kernel.org Subject: [PATCH] cxl: Fix wrong comparison in cxl_adapter_context_get() Date: Wed, 4 Jul 2018 20:58:33 +0530 Message-Id: <20180704152833.2288-1-vaibhav@linux.ibm.com> Sender: stable-owner@vger.kernel.org List-ID: 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 Signed-off-by: Vaibhav Jain --- 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