summaryrefslogtreecommitdiff
path: root/lib/test_ubsan.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2025-05-06 16:39:25 +1000
committerDave Airlie <airlied@redhat.com>2025-05-06 16:39:25 +1000
commit5e0c67998152bdb91b056160449ee542b86271a5 (patch)
treedff9fd979b0319dd2ed873a77246950d7ed95ceb /lib/test_ubsan.c
parent135130db6ee6500e6c82cf44dd831c3fe15f7b5f (diff)
parent92a09c47464d040866cf2b4cd052bc60555185fb (diff)
BackMerge tag 'v6.15-rc5' into drm-next
Linux 6.15-rc5, requested by tzimmerman for fixes required in drm-next. Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'lib/test_ubsan.c')
-rw-r--r--lib/test_ubsan.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/test_ubsan.c b/lib/test_ubsan.c
index 8772e5edaa4f..a4b6f52b9c57 100644
--- a/lib/test_ubsan.c
+++ b/lib/test_ubsan.c
@@ -77,18 +77,22 @@ static void test_ubsan_shift_out_of_bounds(void)
static void test_ubsan_out_of_bounds(void)
{
- volatile int i = 4, j = 5, k = -1;
- volatile char above[4] = { }; /* Protect surrounding memory. */
- volatile int arr[4];
- volatile char below[4] = { }; /* Protect surrounding memory. */
+ int i = 4, j = 4, k = -1;
+ volatile struct {
+ char above[4]; /* Protect surrounding memory. */
+ int arr[4];
+ char below[4]; /* Protect surrounding memory. */
+ } data;
- above[0] = below[0];
+ OPTIMIZER_HIDE_VAR(i);
+ OPTIMIZER_HIDE_VAR(j);
+ OPTIMIZER_HIDE_VAR(k);
UBSAN_TEST(CONFIG_UBSAN_BOUNDS, "above");
- arr[j] = i;
+ data.arr[j] = i;
UBSAN_TEST(CONFIG_UBSAN_BOUNDS, "below");
- arr[k] = i;
+ data.arr[k] = i;
}
enum ubsan_test_enum {