diff options
| author | Charles Han <hanchunchao@inspur.com> | 2025-01-10 16:42:37 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-08 09:57:57 +0100 |
| commit | c6896bf4c611c3dd126f3e03685f2360a18b3d6f (patch) | |
| tree | fd81fe1107cb0c8e8933163d574acd559ec700d0 /drivers | |
| parent | 19b248069d1b1424982723a2bf3941ad864d5204 (diff) | |
| download | linux-c6896bf4c611c3dd126f3e03685f2360a18b3d6f.tar.gz linux-c6896bf4c611c3dd126f3e03685f2360a18b3d6f.tar.bz2 linux-c6896bf4c611c3dd126f3e03685f2360a18b3d6f.zip | |
firewire: test: Fix potential null dereference in firewire kunit test
[ Upstream commit 352fafe97784e81a10a7c74bd508f71a19b53c2a ]
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: 1c8506d62624 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/firewire/device-attribute-test.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/device-attribute-test.c index 2f123c6b0a16..97478a96d1c9 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -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. |
