[PATCH] btrfs: add missing NULL check in btrfs_free_tree_block()

From: Riyan Dhiman
Date: Thu Sep 26 2024 - 09:57:46 EST


> If that happens we want it to be noisy so that it gets reported and we
> look at it.
> Letting a NULL pointer dereference happen is one way of getting our attention.
>
> O more gentle and explicit way would be to have a: ASSERT(bg != NULL);

I am wondering whether it would be better to have an ASSERT statement here, as you
suggested, or use a BUG_ON instead.

I haven't personally encountered a null pointer dereference issue in a live kernel
environment, so I'm not sure how the kernel behaves in such a scenario. However, it
seems wrong to leave it unhandled as it currently is.

Regards,
Riyan Dhiman