Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5993080pxb; Tue, 16 Feb 2021 12:58:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyj7aD9SX0Rk3urkdq+MZPE4ZA/dSu0ydTfad24w83RgQK8GgkaffITMttcPjYZ3MKxy7Q6 X-Received: by 2002:aa7:cb53:: with SMTP id w19mr18881893edt.324.1613509091287; Tue, 16 Feb 2021 12:58:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613509091; cv=none; d=google.com; s=arc-20160816; b=g/s5ioYsAmLN3g6cxf0SViHWWMB3G/jlZojK4Cg2dudQ62BnM6hm1obkL4MB+fjN3X 4fjqsLUliDbF/3tUU7ceFUwlvYJDe8sufKMk5ala/DX5J87A0sbwqKkv893XLxjqCKcm 0rCsrg9D5ENtbzcvbYgooVFhf9gaksol9zSXmSpuiq1gzXxQN0K9biTDZDK2eGXzzYlU D4gdFw6WKiI5Ae71rh+BXG8lwLj9V/6mw45hw2e9i540/3rQPtLGKLdt5mqzgE7QIHcg 8HMDuxIcK2ltstdKC6cfEslRTZOGWW6K7n+ibNvyRoYc2d9y68RWAGQMUKZ8Ees6Di44 b70A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YFshz0e56kZ+qQSxqouSNCJV43gofQ0AnIxpI0Z2FsM=; b=gK758KEFYrF7t7Wqdd3ohj7ekuioycO0WFt8U7mhQWzqNfsFaPZhb7la6VWWafUIjb 4RT8DTpNhd52LjIX7NCgtOW4zLpioahXwZgApWnfbgcF/D3PmluYOd1SzdtX9uiDt424 evCIu3torFhCU7HpEPhnUdE7sHtxU4EE1hkbtNW3aRZwlgcp7tAiBLs8V88OU2a4bg1E GfWSr4PAKiD2C6uq1+NjxV+kXiEXZDTQ9Dv5ACHtqRS4GFGkCwTi1IavkFX5UZu+CRtA g+vmFPNDHHYSM+5bNlpj8MMOs84EFuxgfhtkw2f0K8qFktCBrg97rOZMbuMTSN8EeVOR koKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=BhUw3SJk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p14si7860584edm.81.2021.02.16.12.57.46; Tue, 16 Feb 2021 12:58:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=BhUw3SJk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbhBPUxj (ORCPT + 99 others); Tue, 16 Feb 2021 15:53:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbhBPUxi (ORCPT ); Tue, 16 Feb 2021 15:53:38 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4740C061756 for ; Tue, 16 Feb 2021 12:52:57 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id b14so12793694eju.7 for ; Tue, 16 Feb 2021 12:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YFshz0e56kZ+qQSxqouSNCJV43gofQ0AnIxpI0Z2FsM=; b=BhUw3SJkYjGoMCMl/NP6DA3khVYOouIHGxo9KByiOKCADD2ds440N2P1NZ6Zhyl0Au 1FnlyPFmkZFoayIO9K3JEFGfjoE2B+7GZKsTBxe+HPRxQm44NaGEgPBUt5xDAxbWJ2qm EA4ucRuGXcJGtTCJgL7ioctJc6SPahzKXFpS/i7d9TQoAa54QKf24Z18Fj9slVMHb6Cn UEGmTU6U9CKFWnE0/4Ujz/bk82BFUf9F/H0cBTgknKtzAOWdHdCUOoVHp9pjSdHLGGCa 7+PNchMClFu+MM2n7AbPWzLfIRp8SFt75WUv4f5S+C0Lf+Q4B2KvAKjh3qCjHxVxCib1 ikEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YFshz0e56kZ+qQSxqouSNCJV43gofQ0AnIxpI0Z2FsM=; b=eKVKW703iu1kapCyH8O0o0MgVyA/5b9+7d4I8gJznx0tt+d8RtfH+OZL0FOyraH6Jw D0By4OeBnabd4cvCAmQfHctLJT4syaXIz95CmDN2XsvI8yvRyqTzUd7UXvsWV02S5Qda tQxoDdU1vFxC3cbUm7eyWc4R9RpeS14GrVahgvMYRDoWApWIrVkwmiCX5ebYwLZi+0pR M66M5fdCzP/qYOG1Y4RKvYuiozvPDwHXmzrd+vCTPBELqVhoZ4U02aTW/g0p8LvLTzfp 6d18dn6NG+rftV0LNi+0oApG99I/nzqaKy2QHs2yAutAJ2+CCzDqKoIEIv6dU8ZRjJ3n wtLQ== X-Gm-Message-State: AOAM531QUnnlDEbX/Ry6IYHmAf41J/9muzt9Pn66hyqMhlRiIaJXxhOx zvUM5hh7W9WEaoqNpgxjJXcwhIh4aDvnIxuo8pguSw== X-Received: by 2002:a17:906:fad4:: with SMTP id lu20mr11327016ejb.341.1613508776303; Tue, 16 Feb 2021 12:52:56 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Dan Williams Date: Tue, 16 Feb 2021 12:52:46 -0800 Message-ID: Subject: Re: [PATCH] cxl/mem: Fix an error code in cxl_mem_mbox_get() To: Dan Carpenter Cc: Alison Schofield , Ben Widawsky , Vishal Verma , Ira Weiny , linux-cxl@vger.kernel.org, Linux Kernel Mailing List , kernel-janitors@vger.kernel.org, Colin King Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 16, 2021 at 11:17 AM Dan Carpenter wrote: > > Smatch complains that sometimes when we return success we are holding > the mutex and sometimes we have released the mutex. It turns out that > the bug is a missing error code if the mbox is not ready. It should > return -EBUSY instead of success. > > Fixes: cc1967ac93ab ("cxl/mem: Find device capabilities") > Signed-off-by: Dan Carpenter > --- > drivers/cxl/mem.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c > index 3bca8451348a..2ebc84e4d202 100644 > --- a/drivers/cxl/mem.c > +++ b/drivers/cxl/mem.c > @@ -383,8 +383,8 @@ static int __cxl_mem_mbox_send_cmd(struct cxl_mem *cxlm, > static int cxl_mem_mbox_get(struct cxl_mem *cxlm) > { > struct device *dev = &cxlm->pdev->dev; > - int rc = -EBUSY; > u64 md_status; > + int rc; > > mutex_lock_io(&cxlm->mbox_mutex); > > @@ -414,6 +414,7 @@ static int cxl_mem_mbox_get(struct cxl_mem *cxlm) > md_status = readq(cxlm->memdev_regs + CXLMDEV_STATUS_OFFSET); > if (!(md_status & CXLMDEV_MBOX_IF_READY && CXLMDEV_READY(md_status))) { > dev_err(dev, "mbox: reported doorbell ready, but not mbox ready\n"); > + rc = -EBUSY; > goto out; Hey, Smatch gave a more thorough report than Coverity: http://lore.kernel.org/r/20210215195313.90231-1-colin.king@canonical.com