Skip to content

iio: hid-sensors: fix shared callbacks in temperature and humidity

Christopher Hoover linux-iio linux-input lkml stable 3 versions – Applied

Status from this message: Applied to the fixes-togreg branch of iio.git with the ordering tweaks Andy suggested.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 14 repliesApplied
  2. v23 patches 5 repliesSuperseded
  3. v12 patches 0 repliesSuperseded

Changes in v3 from the cover letter

- Patches 2-3: set the callbacks with one compound literal (Jonathan).
- Kept Joshua's Reviewed-by on all three; patches 2-3 changed only in style.
- Rebased onto v7.3.
- Sent as a new thread, not a reply to v2.

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/3HID: hid-sensor-hub: Synchronize callback removal with raw eventsdrivers/hid/hid-sensor-hub.c+10 -25 replies
2/3iio: temperature: hid-sensor-temperature: Use per-instance callbacksdrivers/iio/temperature/hid-sensor-temperature.c+7 -72 replies
3/3iio: humidity: hid-sensor-humidity: Use per-instance callbacksdrivers/iio/humidity/hid-sensor-humidity.c+7 -72 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchJoshua CroftsSrinivas Pandruvada
1/3R-b A-b A-b
2/3R-b A-b
3/3R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/3] iio: hid-sensors: fix shared callbacks in temperature and humidity

hid-sensor-temperature and hid-sensor-humidity share one static struct hid_sensor_hub_callbacks across instances and overwrite its pdev on every probe. With two temperature sensors, reports for one go to the other's pdev; once that device is removed, temperature_capture_sample() dereferences NULL. I hit this on 7.0 with two uhid-created sensors.

Patches 2-3 make the callbacks per instance, as the other HID sensor drivers do. Patch 1 makes sensor_hub_remove_callback() take pdata->lock, as sensor_hub_raw_event() does, so a report racing an unbind cannot call through the freed callbacks.

Changes in v3:
- Patches 2-3: set the callbacks with one compound literal (Jonathan).
- Kept Joshua's Reviewed-by on all three; patches 2-3 changed only in style.
- Rebased onto v7.3.
- Sent as a new thread, not a reply to v2.

Changes in v2:
- New patch 1, for the use-after-free on unbind found by the Sashiko review of v1.

v2: https://lore.kernel.org/all/[email protected]/

Christopher Hoover (3):
HID: hid-sensor-hub: Synchronize callback removal with raw events
iio: temperature: hid-sensor-temperature: Use per-instance callbacks
iio: humidity: hid-sensor-humidity: Use per-instance callbacks

 drivers/hid/hid-sensor-hub.c                     | 12 ++++++++++--
 drivers/iio/humidity/hid-sensor-humidity.c       | 14 +++++++-------
 drivers/iio/temperature/hid-sensor-temperature.c | 14 +++++++-------
 3 files changed, 24 insertions(+), 16 deletions(-)

base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222

Signature · 1 line
2.53.0