UPSTREAM: kasan: initialize tag to 0xff in __kasan_kmalloc

Upstream commit 0600597c854e53d2f9b7a6a718c1da2b8b4cb4db.

When building with -Wuninitialized and CONFIG_KASAN_SW_TAGS unset, Clang

mm/kasan/common.c:484:40: warning: variable 'tag' is uninitialized when
used here [-Wuninitialized]
        kasan_unpoison_shadow(set_tag(object, tag), size);

set_tag ignores tag in this configuration but clang doesn't realize it at
this point in its pipeline, as it points to arch_kasan_set_tag as being
the point where it is used, which will later be expanded to (void
*)(object) without a use of tag.  Initialize tag to 0xff, as it removes
this warning and doesn't change the meaning of the code.

Fixes: 7f94ffbc4c6a ("kasan: add hooks implementation for tag-based mode")
Signed-off-by: Nathan Chancellor <>
Reviewed-by: Andrey Konovalov <>
Reviewed-by: Andrey Ryabinin <>
Cc: Alexander Potapenko <>
Cc: Dmitry Vyukov <>
Cc: Nick Desaulniers <>
Cc: <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
Signed-off-by: Andrey Konovalov <>
Change-Id: I5860952772ae66e9eaafe138899e14da1892cab6
Bug: 128674696
1 file changed