summaryrefslogtreecommitdiff
path: root/drivers/hid/hidraw.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-06-29 20:24:40 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2023-06-29 20:24:40 +0300
commit0e382fa72bbf0610be40af9af9b03b0cd149df82 (patch)
treec5469baa5c37252461bf47efccce3812db0e702f /drivers/hid/hidraw.c
parent675285ad819293844018aa8096ba9a6d7c77b90b (diff)
parentb571809ec3b0af1a93d46bb09fece4ddeafe5a97 (diff)
downloadlinux-0e382fa72bbf0610be40af9af9b03b0cd149df82.tar.xz
Merge tag 'for-linus-2023062701' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID updates from Jiri Kosina: - more bullet-proof handling of devres-managed resources in HID core (Dmitry Torokhov) - conversion of hid-wacom to use ktime_t (Jason Gerecke) - touch selftests for hid-wacom (Joshua Dickens) - support for nVidia Thunderstrike (SHIELD 2017) controller (Rahul Rameshbabu) - power management reset-during-suspend fix for goodix Chromebook devices (Fei Shao) - assorted device ID additions, device-specific quirks and code cleanups * tag 'for-linus-2023062701' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (27 commits) HID: wacom: Use ktime_t rather than int when dealing with timestamps HID: hidraw: fix data race on device refcount HID: intel-ish-hid: ipc: Add Arrow Lake PCI device ID HID: logitech-hidpp: add HIDPP_QUIRK_DELAYED_INIT for the T651. HID: add quirk for 03f0:464a HP Elite Presenter Mouse HID: nvidia-shield: Support LED functionality for Thunderstrike HID: nvidia-shield: Add mappings for consumer HID USAGE buttons HID: nvidia-shield: Initial driver implementation with Thunderstrike support HID: apple: Option to swap only left side mod keys HID: uclogic: Modular KUnit tests should not depend on KUNIT=y HID: fix an error code in hid_check_device_match() HID: logitech-hidpp: Add USB and Bluetooth IDs for the Logitech G915 TKL Keyboard HID: i2c-hid: Switch i2c drivers back to use .probe() HID: i2c-hid: goodix: Add support for "goodix,no-reset-during-suspend" property dt-bindings: input: goodix: Add "goodix,no-reset-during-suspend" property HID: microsoft: Add rumble support to latest xbox controllers selftests: hid: Add touch tests for Wacom devices HID: ensure timely release of driver-allocated resources HID: split apart hid_device_probe to make logic more apparent HID: amd_sfh: Split sensor and HID initialization for SFH1.1 ...
Diffstat (limited to 'drivers/hid/hidraw.c')
-rw-r--r--drivers/hid/hidraw.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 93e62b161501..e63c56a0d57f 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -272,7 +272,12 @@ static int hidraw_open(struct inode *inode, struct file *file)
goto out;
}
- down_read(&minors_rwsem);
+ /*
+ * Technically not writing to the hidraw_table but a write lock is
+ * required to protect the device refcount. This is symmetrical to
+ * hidraw_release().
+ */
+ down_write(&minors_rwsem);
if (!hidraw_table[minor] || !hidraw_table[minor]->exist) {
err = -ENODEV;
goto out_unlock;
@@ -301,7 +306,7 @@ static int hidraw_open(struct inode *inode, struct file *file)
spin_unlock_irqrestore(&hidraw_table[minor]->list_lock, flags);
file->private_data = list;
out_unlock:
- up_read(&minors_rwsem);
+ up_write(&minors_rwsem);
out:
if (err < 0)
kfree(list);