Skip to content

Commit 60da744

Browse files
surenbaghdasaryanakpm00
authored andcommitted
alloc_tag: fix set_codetag_empty() when !CONFIG_MEM_ALLOC_PROFILING_DEBUG
It was recently noticed that set_codetag_empty() might be used not only to mark NULL alloctag references as empty to avoid warnings but also to reset valid tags (in clear_page_tag_ref()). Since set_codetag_empty() is defined as NOOP for CONFIG_MEM_ALLOC_PROFILING_DEBUG=n, such use of set_codetag_empty() leads to subtle bugs. Fix set_codetag_empty() for CONFIG_MEM_ALLOC_PROFILING_DEBUG=n to reset the tag reference. Link: https://lkml.kernel.org/r/[email protected] Fixes: a8fc28d ("alloc_tag: introduce clear_page_tag_ref() helper function") Signed-off-by: Suren Baghdasaryan <[email protected]> Reported-by: David Wang <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected]/ Cc: David Wang <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: Mike Rapoport (Microsoft) <[email protected]> Cc: Pasha Tatashin <[email protected]> Cc: Sourav Panda <[email protected]> Cc: Yu Zhao <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent e269b5d commit 60da744

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

include/linux/alloc_tag.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ static inline void set_codetag_empty(union codetag_ref *ref)
6363
#else /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */
6464

6565
static inline bool is_codetag_empty(union codetag_ref *ref) { return false; }
66-
static inline void set_codetag_empty(union codetag_ref *ref) {}
66+
67+
static inline void set_codetag_empty(union codetag_ref *ref)
68+
{
69+
if (ref)
70+
ref->ct = NULL;
71+
}
6772

6873
#endif /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */
6974

0 commit comments

Comments
 (0)