selftests, arm64: fix uninitialized symbol in tags_test.c
authorAndrey Konovalov <andreyknvl@google.com>
Mon, 19 Aug 2019 13:14:42 +0000 (15:14 +0200)
committerWill Deacon <will@kernel.org>
Mon, 19 Aug 2019 15:25:32 +0000 (16:25 +0100)
Fix tagged_ptr not being initialized when TBI is not enabled.

Link: https://www.spinics.net/lists/linux-kselftest/msg09446.html
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
tools/testing/selftests/arm64/tags_test.c

index 22a1b266e3734c4b2a095c21fc2b8cf3f88f3b8e..5701163460ef7ff43e9d138f941821a22e3f3d32 100644 (file)
 int main(void)
 {
        static int tbi_enabled = 0;
-       struct utsname *ptr, *tagged_ptr;
+       unsigned long tag = 0;
+       struct utsname *ptr;
        int err;
 
        if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0) == 0)
                tbi_enabled = 1;
        ptr = (struct utsname *)malloc(sizeof(*ptr));
        if (tbi_enabled)
-               tagged_ptr = (struct utsname *)SET_TAG(ptr, 0x42);
-       err = uname(tagged_ptr);
+               tag = 0x42;
+       ptr = (struct utsname *)SET_TAG(ptr, tag);
+       err = uname(ptr);
        free(ptr);
 
        return err;