Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bcache: Remove unnecessary NULL point check in node allocations

Due to the previous 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 by an IS_ERR check.

Fixes: cafe56359144 ("bcache: A block layer cache")
Cc: stable@vger.kernel.org
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Signed-off-by: Coly Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20230615121223.22502-5-colyli@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Zheng Wang and committed by
Jens Axboe
028ddcac ccb8c3bd

+7 -7
+5 -5
drivers/md/bcache/btree.c
··· 1138 1138 { 1139 1139 struct btree *n = bch_btree_node_alloc(b->c, op, b->level, b->parent); 1140 1140 1141 - if (!IS_ERR_OR_NULL(n)) { 1141 + if (!IS_ERR(n)) { 1142 1142 mutex_lock(&n->write_lock); 1143 1143 bch_btree_sort_into(&b->keys, &n->keys, &b->c->sort); 1144 1144 bkey_copy_key(&n->key, &b->key); ··· 1340 1340 memset(new_nodes, 0, sizeof(new_nodes)); 1341 1341 closure_init_stack(&cl); 1342 1342 1343 - while (nodes < GC_MERGE_NODES && !IS_ERR_OR_NULL(r[nodes].b)) 1343 + while (nodes < GC_MERGE_NODES && !IS_ERR(r[nodes].b)) 1344 1344 keys += r[nodes++].keys; 1345 1345 1346 1346 blocks = btree_default_blocks(b->c) * 2 / 3; ··· 1352 1352 1353 1353 for (i = 0; i < nodes; i++) { 1354 1354 new_nodes[i] = btree_node_alloc_replacement(r[i].b, NULL); 1355 - if (IS_ERR_OR_NULL(new_nodes[i])) 1355 + if (IS_ERR(new_nodes[i])) 1356 1356 goto out_nocoalesce; 1357 1357 } 1358 1358 ··· 1487 1487 bch_keylist_free(&keylist); 1488 1488 1489 1489 for (i = 0; i < nodes; i++) 1490 - if (!IS_ERR_OR_NULL(new_nodes[i])) { 1490 + if (!IS_ERR(new_nodes[i])) { 1491 1491 btree_node_free(new_nodes[i]); 1492 1492 rw_unlock(true, new_nodes[i]); 1493 1493 } ··· 1669 1669 if (should_rewrite) { 1670 1670 n = btree_node_alloc_replacement(b, NULL); 1671 1671 1672 - if (!IS_ERR_OR_NULL(n)) { 1672 + if (!IS_ERR(n)) { 1673 1673 bch_btree_node_write_sync(n); 1674 1674 1675 1675 bch_btree_set_root(n);
+2 -2
drivers/md/bcache/super.c
··· 1723 1723 if (!IS_ERR_OR_NULL(c->gc_thread)) 1724 1724 kthread_stop(c->gc_thread); 1725 1725 1726 - if (!IS_ERR_OR_NULL(c->root)) 1726 + if (!IS_ERR(c->root)) 1727 1727 list_add(&c->root->list, &c->btree_cache); 1728 1728 1729 1729 /* ··· 2087 2087 2088 2088 err = "cannot allocate new btree root"; 2089 2089 c->root = __bch_btree_node_alloc(c, NULL, 0, true, NULL); 2090 - if (IS_ERR_OR_NULL(c->root)) 2090 + if (IS_ERR(c->root)) 2091 2091 goto err; 2092 2092 2093 2093 mutex_lock(&c->root->write_lock);