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: <CAB9dFdvV-gEfRY_bsF_hBDErWW=9WUCVsGSmkv6XLE=Y-Lh-Hw@mail.gmail.com>
Date:   Mon, 12 Jul 2021 11:04:06 -0300
From:   Marc Dionne <marc.c.dionne@...il.com>
To:     David Howells <dhowells@...hat.com>
Cc:     linux-afs@...ts.infradead.org,
        Abaci Robot <abaci@...ux.alibaba.com>,
        Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>,
        linux-fsdevel@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] afs: Remove redundant assignment to ret

On Mon, Jul 12, 2021 at 9:57 AM David Howells <dhowells@...hat.com> wrote:
>
> From: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
>
> Variable ret is set to -ENOENT and -ENOMEM but this value is never
> read as it is overwritten or not used later on, hence it is a
> redundant assignment and can be removed.
>
> Cleans up the following clang-analyzer warning:
>
> fs/afs/dir.c:2014:4: warning: Value stored to 'ret' is never read
> [clang-analyzer-deadcode.DeadStores].
>
> fs/afs/dir.c:659:2: warning: Value stored to 'ret' is never read
> [clang-analyzer-deadcode.DeadStores].
>
> [DH made the following modifications:
>
>  - In afs_rename(), -ENOMEM should be placed in op->error instead of ret,
>    rather than the assignment being removed entirely.  afs_put_operation()
>    will pick it up from there and return it.
>
>  - If afs_sillyrename() fails, its error code should be placed in op->error
>    rather than in ret also.
> ]
>
> Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept")
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
> Signed-off-by: David Howells <dhowells@...hat.com>
> cc: linux-afs@...ts.infradead.org
> Link: https://lore.kernel.org/r/1619691492-83866-1-git-send-email-jiapeng.chong@linux.alibaba.com
> ---
>
>  fs/afs/dir.c |   10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index 78719f2f567e..ac829e63c570 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -656,7 +656,6 @@ static int afs_do_lookup_one(struct inode *dir, struct dentry *dentry,
>                 return ret;
>         }
>
> -       ret = -ENOENT;
>         if (!cookie.found) {
>                 _leave(" = -ENOENT [not found]");
>                 return -ENOENT;
> @@ -2020,17 +2019,20 @@ static int afs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
>
>                 if (d_count(new_dentry) > 2) {
>                         /* copy the target dentry's name */
> -                       ret = -ENOMEM;
>                         op->rename.tmp = d_alloc(new_dentry->d_parent,
>                                                  &new_dentry->d_name);
> -                       if (!op->rename.tmp)
> +                       if (!op->rename.tmp) {
> +                               op->error = -ENOMEM;
>                                 goto error;
> +                       }
>
>                         ret = afs_sillyrename(new_dvnode,
>                                               AFS_FS_I(d_inode(new_dentry)),
>                                               new_dentry, op->key);
> -                       if (ret)
> +                       if (ret) {
> +                               op->error = ret;
>                                 goto error;
> +                       }
>
>                         op->dentry_2 = op->rename.tmp;
>                         op->rename.rehash = NULL;
>
>
>
> _______________________________________________
> linux-afs mailing list
> http://lists.infradead.org/mailman/listinfo/linux-afs

Reviewed-by: Marc Dionne <marc.dionne@...istor.com>

Marc

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ