@@ -324,6 +324,9 @@ static void krealloc_more_oob_helper(struct kunit *test,
char *ptr1, *ptr2;
size_t middle;
+ OPTIMIZER_HIDE_VAR(size1);
+ OPTIMIZER_HIDE_VAR(size2);
+
KUNIT_ASSERT_LT(test, size1, size2);
middle = size1 + (size2 - size1) / 2;
@@ -356,6 +359,9 @@ static void krealloc_less_oob_helper(struct kunit *test,
char *ptr1, *ptr2;
size_t middle;
+ OPTIMIZER_HIDE_VAR(size1);
+ OPTIMIZER_HIDE_VAR(size2);
+
KUNIT_ASSERT_LT(test, size2, size1);
middle = size2 + (size1 - size2) / 2;
@@ -578,13 +584,14 @@ static void kmalloc_memmove_invalid_size(struct kunit *test)
{
char *ptr;
size_t size = 64;
- volatile size_t invalid_size = size;
+ size_t invalid_size = size;
ptr = kmalloc(size, GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
memset((char *)ptr, 0, 64);
OPTIMIZER_HIDE_VAR(ptr);
+ OPTIMIZER_HIDE_VAR(invalid_size);
KUNIT_EXPECT_KASAN_FAIL(test,
memmove((char *)ptr, (char *)ptr + 4, invalid_size));
kfree(ptr);