lkml.org 
[lkml]   [2018]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 21/89] cxl: Fix wrong comparison in cxl_adapter_context_get()
    Date
    4.14-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Vaibhav Jain <vaibhav@linux.ibm.com>

    commit ef6cb5f1a048fdf91ccee6d63d2bfa293338502d upstream.

    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>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/misc/cxl/main.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    --- a/drivers/misc/cxl/main.c
    +++ b/drivers/misc/cxl/main.c
    @@ -287,7 +287,7 @@ int cxl_adapter_context_get(struct cxl *
    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)

    \
     
     \ /
      Last update: 2018-09-07 23:57    [W:5.724 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site