kunit: fix bug in KUNIT_EXPECT_MEMEQ
authorRae Moar <rmoar@google.com>
Fri, 27 Jan 2023 20:39:50 +0000 (20:39 +0000)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 30 Jan 2023 21:46:46 +0000 (14:46 -0700)
commitdd2f0a0a2f751b7aafaea5cbba8e65a55fd12f94
treef5a7a878dc3f10a89120ffce3876013a9357bc00
parentdb105c37a4d69d684c1edf2915557463d0ba172c
kunit: fix bug in KUNIT_EXPECT_MEMEQ

In KUNIT_EXPECT_MEMEQ and KUNIT_EXPECT_MEMNEQ, add check if one of the
inputs is NULL and fail if this is the case.

Currently, the kernel crashes if one of the inputs is NULL. Instead,
fail the test and add an appropriate error message.

Fixes: b8a926bea8b1 ("kunit: Introduce KUNIT_EXPECT_MEMEQ and KUNIT_EXPECT_MEMNEQ macros")
This was found by the kernel test robot:
https://lore.kernel.org/all/202212191448.D6EDPdOh-lkp@intel.com/

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
include/kunit/test.h
lib/kunit/assert.c