On Tue, Nov 3, 2020 at 11:33 AM Robert Hancock <robert.hancock@xxxxxxxxxx> wrote: > > As part of commit a919ba06979a7 ("hwmon: (pmbus) Stop caching register > values"), the update of the sensor value is now triggered directly by the > sensor attribute value being read from sysfs. This created (or at least > made much more likely) a locking issue, since nothing protected the device > page selection from being unexpectedly modified by concurrent reads. If > sensor values on different pages on the same device were being concurrently > read by multiple threads, this could cause spurious read errors due to the > page register not reading back the same value last written, or sensor > values being read from the incorrect page. > > Add locking of the update_lock mutex in pmbus_show_sensor and > pmbus_show_samples so that these cannot result in concurrent reads from the > underlying device. > > Fixes: a919ba06979a7 ("hwmon: (pmbus) Stop caching register values") > Signed-off-by: Robert Hancock <robert.hancock@xxxxxxxxxx> Reviewed-by: Alex Qiu <xqiu@xxxxxxxxxx> Hi Robert, Thanks for raising this issue up! - Alex Qiu