* [bug report] bcachefs: missing error checking in __bch2_btree_root_alloc()
@ 2023-10-12 9:43 Dan Carpenter
2024-01-25 14:38 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-10-12 9:43 UTC (permalink / raw)
To: kent.overstreet; +Cc: linux-bcachefs
Hello Kent Overstreet,
The patch e0750d947352: "bcachefs: Initial commit" from Mar 16, 2017
(linux-next), leads to the following Smatch static checker warning:
fs/bcachefs/btree_update_interior.c:2336 __bch2_btree_root_alloc()
error: 'b' dereferencing possible ERR_PTR()
fs/bcachefs/btree_update_interior.c
2319 static int __bch2_btree_root_alloc(struct btree_trans *trans, enum btree_id id)
2320 {
2321 struct bch_fs *c = trans->c;
2322 struct closure cl;
2323 struct btree *b;
2324 int ret;
2325
2326 closure_init_stack(&cl);
2327
2328 do {
2329 ret = bch2_btree_cache_cannibalize_lock(c, &cl);
2330 closure_sync(&cl);
2331 } while (ret);
2332
2333 b = bch2_btree_node_mem_alloc(trans, false);
Smatch complains that bch2_btree_node_mem_alloc() can fail
2334 bch2_btree_cache_cannibalize_unlock(c);
2335
--> 2336 set_btree_node_fake(b);
^
Leading to a crash.
2337 set_btree_node_need_rewrite(b);
2338 b->c.level = 0;
2339 b->c.btree_id = id;
2340
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] bcachefs: missing error checking in __bch2_btree_root_alloc()
2023-10-12 9:43 [bug report] bcachefs: missing error checking in __bch2_btree_root_alloc() Dan Carpenter
@ 2024-01-25 14:38 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2024-01-25 14:38 UTC (permalink / raw)
To: kent.overstreet; +Cc: linux-bcachefs
On Thu, Oct 12, 2023 at 12:43:46PM +0300, Dan Carpenter wrote:
> Hello Kent Overstreet,
>
> The patch e0750d947352: "bcachefs: Initial commit" from Mar 16, 2017
> (linux-next), leads to the following Smatch static checker warning:
>
> fs/bcachefs/btree_update_interior.c:2336 __bch2_btree_root_alloc()
> error: 'b' dereferencing possible ERR_PTR()
>
> fs/bcachefs/btree_update_interior.c
> 2319 static int __bch2_btree_root_alloc(struct btree_trans *trans, enum btree_id id)
> 2320 {
> 2321 struct bch_fs *c = trans->c;
> 2322 struct closure cl;
> 2323 struct btree *b;
> 2324 int ret;
> 2325
> 2326 closure_init_stack(&cl);
> 2327
> 2328 do {
> 2329 ret = bch2_btree_cache_cannibalize_lock(c, &cl);
> 2330 closure_sync(&cl);
> 2331 } while (ret);
> 2332
> 2333 b = bch2_btree_node_mem_alloc(trans, false);
>
> Smatch complains that bch2_btree_node_mem_alloc() can fail
>
> 2334 bch2_btree_cache_cannibalize_unlock(c);
> 2335
> --> 2336 set_btree_node_fake(b);
> ^
> Leading to a crash.
Smatch still complains about this in linux-next.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-25 14:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-12 9:43 [bug report] bcachefs: missing error checking in __bch2_btree_root_alloc() Dan Carpenter
2024-01-25 14:38 ` Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.