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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1A4D30F2-5FCB-4498-9571-12B320F4E1A1@suse.de>
Date:   Fri, 3 Feb 2023 10:46:00 +0800
From:   Coly Li <colyli@...e.de>
To:     Zheng Hacker <hackerzheng666@...il.com>
Cc:     Zheng Wang <zyytlz.wz@....com>, stable@...r.kernel.org,
        Kent Overstreet <kent.overstreet@...il.com>,
        linux-bcache@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
        alex000young@...il.com
Subject: Re: [PATCH] bcache: Remove some unnecessary NULL point check for the
 return value of __bch_btree_node_alloc-related pointer



> 2023年2月3日 10:43,Zheng Hacker <hackerzheng666@...il.com> 写道:
> 
> Hello,
> 
> After writing the patch, I found there may be more places to replace
> IS_ERR_OR_NULL to IS_ERR.
> If the alloc of node will never be NULL, the additional NULL check of
> nodes after allocation may also
> be useless. This patch just fixes the check around the alloc. I'm not
> sure about other places for my
> limited understanding of the code in bcache.

This was why I suggested you to post an extra cleanup patch like this.

You may just add more changes as you mentioned into this patch and post another updated version.

Thanks.

Coly Li

> 
> Thanks,
> Zheng Wang
> 
> Zheng Wang <zyytlz.wz@....com> 于2023年2月3日周五 10:28写道:
>> 
>> Due to the previously fix of __bch_btree_node_alloc, the return value will
>> never be a NULL pointer. So IS_ERR is enough to handle the failure
>> situation. Fix it by replacing IS_ERR_OR_NULL check to IS_ERR check.
>> 
>> Fixes: cafe56359144 ("bcache: A block layer cache")
>> Signed-off-by: Zheng Wang <zyytlz.wz@....com>
>> ---
>> drivers/md/bcache/btree.c | 6 +++---
>> drivers/md/bcache/super.c | 2 +-
>> 2 files changed, 4 insertions(+), 4 deletions(-)
>> 
>> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
>> index 147c493a989a..417cd7c436c4 100644
>> --- a/drivers/md/bcache/btree.c
>> +++ b/drivers/md/bcache/btree.c
>> @@ -1138,7 +1138,7 @@ static struct btree *btree_node_alloc_replacement(struct btree *b,
>> {
>>        struct btree *n = bch_btree_node_alloc(b->c, op, b->level, b->parent);
>> 
>> -       if (!IS_ERR_OR_NULL(n)) {
>> +       if (!IS_ERR(n)) {
>>                mutex_lock(&n->write_lock);
>>                bch_btree_sort_into(&b->keys, &n->keys, &b->c->sort);
>>                bkey_copy_key(&n->key, &b->key);
>> @@ -1352,7 +1352,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
>> 
>>        for (i = 0; i < nodes; i++) {
>>                new_nodes[i] = btree_node_alloc_replacement(r[i].b, NULL);
>> -               if (IS_ERR_OR_NULL(new_nodes[i]))
>> +               if (IS_ERR(new_nodes[i]))
>>                        goto out_nocoalesce;
>>        }
>> 
>> @@ -1669,7 +1669,7 @@ static int bch_btree_gc_root(struct btree *b, struct btree_op *op,
>>        if (should_rewrite) {
>>                n = btree_node_alloc_replacement(b, NULL);
>> 
>> -               if (!IS_ERR_OR_NULL(n)) {
>> +               if (!IS_ERR(n)) {
>>                        bch_btree_node_write_sync(n);
>> 
>>                        bch_btree_set_root(n);
>> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
>> index ba3909bb6bea..92de714fe75e 100644
>> --- a/drivers/md/bcache/super.c
>> +++ b/drivers/md/bcache/super.c
>> @@ -2088,7 +2088,7 @@ static int run_cache_set(struct cache_set *c)
>> 
>>                err = "cannot allocate new btree root";
>>                c->root = __bch_btree_node_alloc(c, NULL, 0, true, NULL);
>> -               if (IS_ERR_OR_NULL(c->root))
>> +               if (IS_ERR(c->root))
>>                        goto err;
>> 
>>                mutex_lock(&c->root->write_lock);
>> --
>> 2.25.1
>> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ