mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
firewire: test: Fix potential null dereference in firewire kunit test
kunit_kzalloc() may return a NULL pointer, dereferencing it without
NULL check may lead to NULL dereference.
Add a NULL check for test_state.
Fixes: 1c8506d626
("firewire: test: add test of device attributes for simple AV/C device")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
Link: https://lore.kernel.org/r/20250110084237.8877-1-hanchunchao@inspur.com
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
This commit is contained in:
parent
892bb0740b
commit
352fafe977
1 changed files with 2 additions and 0 deletions
|
@ -99,6 +99,7 @@ static void device_attr_simple_avc(struct kunit *test)
|
|||
struct device *unit0_dev = (struct device *)&unit0.device;
|
||||
static const int unit0_expected_ids[] = {0x00ffffff, 0x00ffffff, 0x0000a02d, 0x00010001};
|
||||
char *buf = kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
|
||||
int ids[4] = {0, 0, 0, 0};
|
||||
|
||||
// Ensure associations for node and unit devices.
|
||||
|
@ -180,6 +181,7 @@ static void device_attr_legacy_avc(struct kunit *test)
|
|||
struct device *unit0_dev = (struct device *)&unit0.device;
|
||||
static const int unit0_expected_ids[] = {0x00012345, 0x00fedcba, 0x00abcdef, 0x00543210};
|
||||
char *buf = kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
|
||||
int ids[4] = {0, 0, 0, 0};
|
||||
|
||||
// Ensure associations for node and unit devices.
|
||||
|
|
Loading…
Add table
Reference in a new issue