Skip to content

Commit 4038016

Browse files
surenbaghdasaryantehcaster
authored andcommitted
slab: prevent warnings when slab obj_exts vector allocation fails
When object extension vector allocation fails, we set slab->obj_exts to OBJEXTS_ALLOC_FAIL to indicate the failure. Later, once the vector is successfully allocated, we will use this flag to mark codetag references stored in that vector as empty to avoid codetag warnings. slab_obj_exts() used to retrieve the slab->obj_exts vector pointer checks slab->obj_exts for being either NULL or a pointer with MEMCG_DATA_OBJEXTS bit set. However it does not handle the case when slab->obj_exts equals OBJEXTS_ALLOC_FAIL. Add the missing condition to avoid extra warning. Fixes: 09c4656 ("codetag: debug: introduce OBJEXTS_ALLOC_FAIL to mark failed slab_ext allocations") Reported-by: Shakeel Butt <[email protected]> Closes: https://lore.kernel.org/all/jftidhymri2af5u3xtcqry3cfu6aqzte3uzlznhlaylgrdztsi@5vpjnzpsemf5/ Signed-off-by: Suren Baghdasaryan <[email protected]> Cc: [email protected] # v6.10+ Acked-by: Shakeel Butt <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent 3864e4d commit 4038016

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mm/slab.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,12 @@ static inline struct slabobj_ext *slab_obj_exts(struct slab *slab)
526526
unsigned long obj_exts = READ_ONCE(slab->obj_exts);
527527

528528
#ifdef CONFIG_MEMCG
529-
VM_BUG_ON_PAGE(obj_exts && !(obj_exts & MEMCG_DATA_OBJEXTS),
530-
slab_page(slab));
529+
/*
530+
* obj_exts should be either NULL, a valid pointer with
531+
* MEMCG_DATA_OBJEXTS bit set or be equal to OBJEXTS_ALLOC_FAIL.
532+
*/
533+
VM_BUG_ON_PAGE(obj_exts && !(obj_exts & MEMCG_DATA_OBJEXTS) &&
534+
obj_exts != OBJEXTS_ALLOC_FAIL, slab_page(slab));
531535
VM_BUG_ON_PAGE(obj_exts & MEMCG_DATA_KMEM, slab_page(slab));
532536
#endif
533537
return (struct slabobj_ext *)(obj_exts & ~OBJEXTS_FLAGS_MASK);

0 commit comments

Comments
 (0)