Skip to contentSkip to conversation

HID: core: demote data shortness warning to debug level

PATCH Superseded Matteo Croce 2 participants 2 messages May 23 HID

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: core: demote data shortness warning to debug level

From: Matteo Croce <[email protected]>

Commit 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing bogus memset()") changed the log level of the short report message from debug to warning, flooding syslog on systems with devices that regularly send short reports, in my case an UPS:

    $ dmesg |grep -c 'Event data for report .* was too short'
    35

Demote it back to debug level.

Fixes 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing bogus memset()")
---
 drivers/hid/hid-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/hid-core.c +2 -2
index 41a79e43c82b..76cfed8b93c1 100644
@@ -2050,8 +2050,8 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *
 		return 0;
 
 	if (unlikely(bsize < csize)) {
-		hid_warn_ratelimited(hid, "Event data for report %d is incorrect (%d vs %zu)\n",
-				     report->id, csize, bsize);
+		hid_dbg_ratelimited(hid, "Event data for report %d is incorrect (%d vs %zu)\n",
+				    report->id, csize, bsize);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.50.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The patch modifies the wrong warning message, failing to fix the stated issue and…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch modifies the wrong warning message, failing to fix the stated issue and inappropriately masking a different error. --

commit a5df696ba5cc949fba165e62139d8984b9884331
Author: Matteo Croce <[email protected]>

HID: core: demote data shortness warning to debug level

This commit intends to reduce syslog flooding from devices that regularly send short reports by demoting the "was too short" warning to a debug print.

drivers/hid/hid-core.c int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 * · line 2054

Quoted 12 lines
drivers/hid/hid-core.c +2 -2
index 41a79e43c82b3..76cfed8b93c15 100644
@@ -2050,8 +2050,8 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *
 		return 0;
 
 	if (unlikely(bsize < csize)) {
-		hid_warn_ratelimited(hid, "Event data for report %d is incorrect (%d vs %zu)\n",
-				     report->id, csize, bsize);
+		hid_dbg_ratelimited(hid, "Event data for report %d is incorrect (%d vs %zu)\n",
+				    report->id, csize, bsize);

[Severity: Medium]
Does this change modify the intended warning message?

The commit message notes the intention to silence the "was too short" warning. However, this patch modifies the "is incorrect" warning instead, which triggers when the reported size claims to be larger than the actual buffer size (bsize < csize).

The target "was too short" warning appears further down in the function during the bsize < rsize check.

As a result, this might leave the original syslog flooding issue unresolved while potentially hiding a different transport driver condition.

Quoted 2 lines
drivers/hid/hid-core.c +0 -0
 		return -EINVAL;
 	}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1