lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 16 Feb 2021 12:52:46 -0800
From:   Dan Williams <dan.j.williams@...el.com>
To:     Dan Carpenter <dan.carpenter@...cle.com>
Cc:     Alison Schofield <alison.schofield@...el.com>,
        Ben Widawsky <ben.widawsky@...el.com>,
        Vishal Verma <vishal.l.verma@...el.com>,
        Ira Weiny <ira.weiny@...el.com>, linux-cxl@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org,
        Colin King <colin.king@...onical.com>
Subject: Re: [PATCH] cxl/mem: Fix an error code in cxl_mem_mbox_get()

On Tue, Feb 16, 2021 at 11:17 AM Dan Carpenter <dan.carpenter@...cle.com> 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 <dan.carpenter@...cle.com>
> ---
>  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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ