Linux: -Wuninitialized in mm/kasan/common.c

Created on 30 Apr 2019  路  3Comments  路  Source: ClangBuiltLinux/linux

After turning on -Wuninitialized in scripts/Makefile.extrawarn or KCFLAGS, when CONFIG_KASAN_SW_TAGS is not set (I found this with x86 allyesconfig):

mm/kasan/common.c:490:40: warning: variable 'tag' is uninitialized when used here [-Wuninitialized]
        kasan_unpoison_shadow(set_tag(object, tag), size);
                                              ^~~
mm/kasan/kasan.h:178:65: note: expanded from macro 'set_tag'
#define set_tag(addr, tag)      ((void *)arch_kasan_set_tag((addr), (tag)))
                                                                     ^~~
mm/kasan/common.c:473:8: note: initialize the variable 'tag' to silence this warning
        u8 tag;
              ^
               = '\0'
1 warning generated.

It's not wrong but the comment right above kasan_unpoison_shadow states that tag is ignored when CONFIG_KASAN_SW_TAGS is not set and that checks out when you follow arch_kasan_set_tag, which I assume gets fully evaluated later down in the pipeline. It is simple enough to initialize tag though, unless someone else has a better idea.

-Wuninitialized [BUG] linux [FIXED][LINUX] 5.2

Most helpful comment

All 3 comments

Was this page helpful?
0 / 5 - 0 ratings