[bug report] bio: add allocation cache abstraction

From: Dan Carpenter

Date: Fri Feb 06 2026 - 08:50:05 EST


[ Smatch checking is paused while we raise funding. #SadFace
https://lore.kernel.org/all/aTaiGSbWZ9DJaGo7@stanley.mountain/ -dan ]

Hello Jens Axboe,

Commit be4d234d7aeb ("bio: add allocation cache abstraction") from
Mar 8, 2021 (linux-next), leads to the following Smatch static
checker warning:

block/bio.c:790 bio_cpu_dead()
error: potential null dereference 'bs'. (hlist_entry_safe() returns null)

block/bio.c
785 static int bio_cpu_dead(unsigned int cpu, struct hlist_node *node)
786 {
787 struct bio_set *bs;
788
789 bs = hlist_entry_safe(node, struct bio_set, cpuhp_dead);
--> 790 if (bs->cache) {

It doesn't really make sense to use hlist_entry_safe() instead of
hlist_entry() if we're not going to check for NULL.

791 struct bio_alloc_cache *cache = per_cpu_ptr(bs->cache, cpu);
792
793 bio_alloc_cache_prune(cache, -1U);
794 }
795 return 0;
796 }

regards,
dan carpenter