Merge branch 'for-6.7/uclogic' into for-linus

- fixes for crashes detected by CONFIG_KUNIT_ALL_TESTS in hid-uclogic
  driver (Jinjie Ruan)
This commit is contained in:
Jiri Kosina 2023-11-01 00:18:10 +01:00
commit 1372e73a18
2 changed files with 22 additions and 1 deletions

View File

@ -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);
}

View File

@ -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 */