Skip to content

Commit

Permalink
bcache: revert replacing IS_ERR_OR_NULL with IS_ERR again
Browse files Browse the repository at this point in the history
commit b2e382a upstream.

Commit 028ddca ("bcache: Remove unnecessary NULL point check in
node allocations") leads a NULL pointer deference in cache_set_flush().

1721         if (!IS_ERR_OR_NULL(c->root))
1722                 list_add(&c->root->list, &c->btree_cache);

>From the above code in cache_set_flush(), if previous registration code
fails before allocating c->root, it is possible c->root is NULL as what
it is initialized. __bch_btree_node_alloc() never returns NULL but
c->root is possible to be NULL at above line 1721.

This patch replaces IS_ERR() by IS_ERR_OR_NULL() to fix this.

Fixes: 028ddca ("bcache: Remove unnecessary NULL point check in node allocations")
Signed-off-by: Liequan Che <[email protected]>
Cc: [email protected]
Cc: Zheng Wang <[email protected]>
Reviewed-by: Mingzhe Zou <[email protected]>
Signed-off-by: Coly Li <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Liequan Che authored and gregkh committed Dec 14, 2024
1 parent 48eb6e7 commit fb5fee3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/md/bcache/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@ static void cache_set_flush(struct closure *cl)
if (!IS_ERR_OR_NULL(c->gc_thread))
kthread_stop(c->gc_thread);

if (!IS_ERR(c->root))
if (!IS_ERR_OR_NULL(c->root))
list_add(&c->root->list, &c->btree_cache);

/*
Expand Down

0 comments on commit fb5fee3

Please sign in to comment.