Skip to content

Commit

Permalink
Merge branch 'for-6.7/uclogic' into for-linus
Browse files Browse the repository at this point in the history
- fixes for crashes detected by CONFIG_KUNIT_ALL_TESTS in hid-uclogic
  driver (Jinjie Ruan)
  • Loading branch information
Jiri Kosina committed Oct 31, 2023
2 parents e12f065 + d45f72b commit 1372e73
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions drivers/hid/hid-uclogic-core-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, };
Expand All @@ -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);
}

Expand Down
16 changes: 15 additions & 1 deletion drivers/hid/hid-uclogic-params-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 1372e73

Please sign in to comment.