]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools/mm/page-types: fix ternary operator precedence in sigbus handler
authorYe Liu <liuye@kylinos.cn>
Wed, 13 May 2026 02:21:17 +0000 (10:21 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 2 Jun 2026 22:22:18 +0000 (15:22 -0700)
The ternary operator (?:) has lower precedence than addition (+), so the
expression `off + sigbus_addr ?  sigbus_addr - ptr : 0` was parsed as
`(off + sigbus_addr) ?  (sigbus_addr - ptr) : 0` rather than the intended
`off + (sigbus_addr ?  sigbus_addr - ptr : 0)`.  Add explicit parentheses
to ensure the correct evaluation order.

Link: https://lore.kernel.org/20260513022120.58033-3-ye.liu@linux.dev
Signed-off-by: Ye Liu <liuye@kylinos.cn>
Acked-by: SeongJae Park <sj@kernel.org>
Cc: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/mm/page-types.c

index 6594245217a8d05381d0cc2b6ddbd82f4ed3f42b..66f429f2b698751002ea96ae20b3602be6274b08 100644 (file)
@@ -1000,7 +1000,7 @@ static void walk_file_range(const char *name, int fd,
                        fatal("madvise failed: %s", name);
 
                if (sigsetjmp(sigbus_jmp, 1)) {
-                       end = off + sigbus_addr ? sigbus_addr - ptr : 0;
+                       end = off + (sigbus_addr ? sigbus_addr - ptr : 0);
                        fprintf(stderr, "got sigbus at offset %lld: %s\n",
                                        (long long)end, name);
                        goto got_sigbus;