Skip to content

Commit 1775bee

Browse files
committed
Revert "HID: fix HID device resource race between HID core and debugging support"
This reverts commit 377c4c7 which is commit fc43e9c upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: I80bbce6f594ca4dd9b58d58598d4191112ea095f Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
1 parent ee16988 commit 1775bee

3 files changed

Lines changed: 2 additions & 16 deletions

File tree

drivers/hid/hid-core.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,22 +708,15 @@ static void hid_close_report(struct hid_device *device)
708708
* Free a device structure, all reports, and all fields.
709709
*/
710710

711-
void hiddev_free(struct kref *ref)
711+
static void hid_device_release(struct device *dev)
712712
{
713-
struct hid_device *hid = container_of(ref, struct hid_device, ref);
713+
struct hid_device *hid = to_hid_device(dev);
714714

715715
hid_close_report(hid);
716716
kfree(hid->dev_rdesc);
717717
kfree(hid);
718718
}
719719

720-
static void hid_device_release(struct device *dev)
721-
{
722-
struct hid_device *hid = to_hid_device(dev);
723-
724-
kref_put(&hid->ref, hiddev_free);
725-
}
726-
727720
/*
728721
* Fetch a report description item from the data stream. We support long
729722
* items, though they are not used yet.
@@ -2821,7 +2814,6 @@ struct hid_device *hid_allocate_device(void)
28212814
spin_lock_init(&hdev->debug_list_lock);
28222815
sema_init(&hdev->driver_input_lock, 1);
28232816
mutex_init(&hdev->ll_open_lock);
2824-
kref_init(&hdev->ref);
28252817

28262818
return hdev;
28272819
}

drivers/hid/hid-debug.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,6 @@ static int hid_debug_events_open(struct inode *inode, struct file *file)
11321132
goto out;
11331133
}
11341134
list->hdev = (struct hid_device *) inode->i_private;
1135-
kref_get(&list->hdev->ref);
11361135
file->private_data = list;
11371136
mutex_init(&list->read_mutex);
11381137

@@ -1225,8 +1224,6 @@ static int hid_debug_events_release(struct inode *inode, struct file *file)
12251224
list_del(&list->node);
12261225
spin_unlock_irqrestore(&list->hdev->debug_list_lock, flags);
12271226
kfifo_free(&list->hid_debug_fifo);
1228-
1229-
kref_put(&list->hdev->ref, hiddev_free);
12301227
kfree(list);
12311228

12321229
return 0;

include/linux/hid.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,16 +656,13 @@ struct hid_device { /* device report descriptor */
656656
struct list_head debug_list;
657657
spinlock_t debug_list_lock;
658658
wait_queue_head_t debug_wait;
659-
struct kref ref;
660659

661660
unsigned int id; /* system unique id */
662661

663662
ANDROID_KABI_USE(1, struct { __s32 battery_charge_status; u32 padding; });
664663
ANDROID_KABI_RESERVE(2);
665664
};
666665

667-
void hiddev_free(struct kref *ref);
668-
669666
#define to_hid_device(pdev) \
670667
container_of(pdev, struct hid_device, dev)
671668

0 commit comments

Comments
 (0)