Skip to content

Commit 3f81b3a

Browse files
author
Jiri Kosina
committed
Merge branch 'for-5.16/wacom' into for-linus
- improvement of device management handling (Cai Huoqing, Jason Gerecke)
2 parents a7c2b7e + 3d422a4 commit 3f81b3a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

drivers/hid/wacom_sys.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -881,31 +881,28 @@ static int wacom_add_shared_data(struct hid_device *hdev)
881881
if (!data) {
882882
data = kzalloc(sizeof(struct wacom_hdev_data), GFP_KERNEL);
883883
if (!data) {
884-
retval = -ENOMEM;
885-
goto out;
884+
mutex_unlock(&wacom_udev_list_lock);
885+
return -ENOMEM;
886886
}
887887

888888
kref_init(&data->kref);
889889
data->dev = hdev;
890890
list_add_tail(&data->list, &wacom_udev_list);
891891
}
892892

893+
mutex_unlock(&wacom_udev_list_lock);
894+
893895
wacom_wac->shared = &data->shared;
894896

895-
retval = devm_add_action(&hdev->dev, wacom_remove_shared_data, wacom);
896-
if (retval) {
897-
mutex_unlock(&wacom_udev_list_lock);
898-
wacom_remove_shared_data(wacom);
897+
retval = devm_add_action_or_reset(&hdev->dev, wacom_remove_shared_data, wacom);
898+
if (retval)
899899
return retval;
900-
}
901900

902901
if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH)
903902
wacom_wac->shared->touch = hdev;
904903
else if (wacom_wac->features.device_type & WACOM_DEVICETYPE_PEN)
905904
wacom_wac->shared->pen = hdev;
906905

907-
out:
908-
mutex_unlock(&wacom_udev_list_lock);
909906
return retval;
910907
}
911908

0 commit comments

Comments
 (0)