Skip to content

Commit 575122c

Browse files
gregkhSasha Levin
authored andcommitted
HID: Add HID_CLAIMED_INPUT guards in raw_event callbacks missing them
commit ecfa6f3 upstream. In commit 2ff5baa ("HID: appleir: Fix potential NULL dereference at raw event handle"), we handle the fact that raw event callbacks can happen even for a HID device that has not been "claimed" causing a crash if a broken device were attempted to be connected to the system. Fix up the remaining in-tree HID drivers that forgot to add this same check to resolve the same issue. Cc: Jiri Kosina <jikos@kernel.org> Cc: Benjamin Tissoires <bentiss@kernel.org> Cc: Bastien Nocera <hadess@hadess.net> Cc: linux-input@vger.kernel.org Cc: stable <stable@kernel.org> Assisted-by: gkh_clanker_2000 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Benjamin Tissoires <bentiss@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d620b1e commit 575122c

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

drivers/hid/hid-cmedia.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int cmhid_raw_event(struct hid_device *hid, struct hid_report *report,
9999
{
100100
struct cmhid *cm = hid_get_drvdata(hid);
101101

102-
if (len != CM6533_JD_RAWEV_LEN)
102+
if (len != CM6533_JD_RAWEV_LEN || !(hid->claimed & HID_CLAIMED_INPUT))
103103
goto out;
104104
if (memcmp(data+CM6533_JD_SFX_OFFSET, ji_sfx, sizeof(ji_sfx)))
105105
goto out;

drivers/hid/hid-creative-sb0540.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static int creative_sb0540_raw_event(struct hid_device *hid,
153153
u64 code, main_code;
154154
int key;
155155

156-
if (len != 6)
156+
if (len != 6 || !(hid->claimed & HID_CLAIMED_INPUT))
157157
return 0;
158158

159159
/* From daemons/hw_hiddev.c sb0540_rec() in lirc */

drivers/hid/hid-zydacron.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static int zc_raw_event(struct hid_device *hdev, struct hid_report *report,
114114
unsigned key;
115115
unsigned short index;
116116

117-
if (report->id == data[0]) {
117+
if (report->id == data[0] && (hdev->claimed & HID_CLAIMED_INPUT)) {
118118

119119
/* break keys */
120120
for (index = 0; index < 4; index++) {

0 commit comments

Comments
 (0)