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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH6sp9NuonymjV0n2nsChcTKZ6sq5+S_s3uQ-48M0mY9LQh9mg@mail.gmail.com>
Date:   Tue, 27 Jun 2017 11:06:44 +0200
From:   Frans Klaver <fransklaver@...il.com>
To:     Matias Bjørling <m@...rling.me>
Cc:     axboe@...com, linux-block@...r.kernel.org,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Rakesh Pandit <rakesh@...era.com>,
        Matias Bjørling <matias@...xlabs.com>
Subject: Re: [PATCH] ligtnvm: if LUNs are already allocated fix return

On Tue, Jun 27, 2017 at 10:39 AM, Matias Bjørling <m@...rling.me> wrote:
> From: Rakesh Pandit <rakesh@...era.com>
>
> While creating new device with NVM_DEV_CREATE if LUNs are already
> allocated ioctl would return -ENOMEM which is wrong.  This patch
> propagates -EBUSY from nvm_reserve_luns which is correct response.
>
> Fixes: ade69e243 ("lightnvm: merge gennvm with core")
> Signed-off-by: Rakesh Pandit <rakesh@...era.com>
> Signed-off-by: Matias Bjørling <matias@...xlabs.com>
> ---
>  drivers/lightnvm/core.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> index b8f82f5..9ff348f 100644
> --- a/drivers/lightnvm/core.c
> +++ b/drivers/lightnvm/core.c
> @@ -235,7 +235,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
>         struct nvm_target *t;
>         struct nvm_tgt_dev *tgt_dev;
>         void *targetdata;
> -       int ret;
> +       int ret = 0;

Is there any way that you can reach a 'return ret' without having ret
set by some other assignment?


>         tt = nvm_find_target_type(create->tgttype, 1);
>         if (!tt) {
> @@ -252,8 +252,9 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
>         }
>         mutex_unlock(&dev->mlock);
>
> -       if (nvm_reserve_luns(dev, s->lun_begin, s->lun_end))
> -               return -ENOMEM;
> +       ret = nvm_reserve_luns(dev, s->lun_begin, s->lun_end);
> +       if (ret)
> +               goto err;

Why don't you return err straight away here?


>         t = kmalloc(sizeof(struct nvm_target), GFP_KERNEL);
>         if (!t) {
> @@ -314,8 +315,8 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
>         mutex_lock(&dev->mlock);
>         list_add_tail(&t->list, &dev->targets);
>         mutex_unlock(&dev->mlock);
> -
> -       return 0;
> +err:
> +       return ret;

This should not be necessary. In any case, the de-init order should
always be the reverse of the init order, so we don't end up confused.

Frans

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ