diff options
author | Jiri Kosina <jkosina@suse.cz> | 2023-11-01 00:18:10 +0100 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2023-11-01 00:18:10 +0100 |
commit | 1372e73a18139d4f74731cc900085a6bf3c59daf (patch) | |
tree | 2d717393c916bcb4a92ef22eb1adf1d65e7af1f8 /drivers/hid | |
parent | Merge branch 'for-6.7/selftests' into for-linus (diff) | |
parent | HID: uclogic: Fix a work->entry not empty bug in __queue_work() (diff) | |
download | linux-1372e73a18139d4f74731cc900085a6bf3c59daf.tar.xz linux-1372e73a18139d4f74731cc900085a6bf3c59daf.zip |
Merge branch 'for-6.7/uclogic' into for-linus
- fixes for crashes detected by CONFIG_KUNIT_ALL_TESTS in hid-uclogic
driver (Jinjie Ruan)
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-uclogic-core-test.c | 7 | ||||
-rw-r--r-- | drivers/hid/hid-uclogic-params-test.c | 16 |
2 files changed, 22 insertions, 1 deletions
diff --git a/drivers/hid/hid-uclogic-core-test.c b/drivers/hid/hid-uclogic-core-test.c index 2bb916226a38..cb274cde3ad2 100644 --- a/drivers/hid/hid-uclogic-core-test.c +++ b/drivers/hid/hid-uclogic-core-test.c @@ -56,6 +56,11 @@ static struct uclogic_raw_event_hook_test test_events[] = { }, }; +static void fake_work(struct work_struct *work) +{ + +} + static void hid_test_uclogic_exec_event_hook_test(struct kunit *test) { struct uclogic_params p = {0, }; @@ -77,6 +82,8 @@ static void hid_test_uclogic_exec_event_hook_test(struct kunit *test) KUNIT_ASSERT_NOT_ERR_OR_NULL(test, filter->event); memcpy(filter->event, &hook_events[n].event[0], filter->size); + INIT_WORK(&filter->work, fake_work); + list_add_tail(&filter->list, &p.event_hooks->list); } diff --git a/drivers/hid/hid-uclogic-params-test.c b/drivers/hid/hid-uclogic-params-test.c index 678f50cbb160..a30121419a29 100644 --- a/drivers/hid/hid-uclogic-params-test.c +++ b/drivers/hid/hid-uclogic-params-test.c @@ -174,12 +174,26 @@ static void hid_test_uclogic_parse_ugee_v2_desc(struct kunit *test) KUNIT_EXPECT_EQ(test, params->frame_type, frame_type); } +struct fake_device { + unsigned long quirks; +}; + static void hid_test_uclogic_params_cleanup_event_hooks(struct kunit *test) { int res, n; + struct hid_device *hdev; + struct fake_device *fake_dev; struct uclogic_params p = {0, }; - res = uclogic_params_ugee_v2_init_event_hooks(NULL, &p); + hdev = kunit_kzalloc(test, sizeof(struct hid_device), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hdev); + + fake_dev = kunit_kzalloc(test, sizeof(struct fake_device), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fake_dev); + + hid_set_drvdata(hdev, fake_dev); + + res = uclogic_params_ugee_v2_init_event_hooks(hdev, &p); KUNIT_ASSERT_EQ(test, res, 0); /* Check that the function can be called repeatedly */ |