Re: [PATCH v3] iio: temperature: tsys02d: Fix state desynchronization on resolution write error
From: Joshua Crofts
Date: Mon Oct 05 2026 - 10:20:19 EST
On Mon, 5 Oct 2026 14:20:02 +0100
Salah Triki <salah.triki@xxxxxxxxx> wrote:
> In tsys02d_write_raw(), dev_data->res_index is updated before checking
> the return value of ms_sensors_write_resolution(). If the hardware I2C
> write operation fails, dev_data->res_index remains updated with the
> new index despite the physical sensor remaining in its previous state.
>
> This leads to a state desynchronization where subsequent reads via
> tsys02d_read_raw() return an incorrect sampling frequency.
>
> Fix this by handling the error path first, updating dev_data->res_index
> only on success, and using guard(mutex) to clean up locking.
>
> This was found through manual code review.
>
> Fixes: 53bf4d067d51 ("Add tsys02d meas-spec driver support")
> Signed-off-by: Salah Triki <salah.triki@xxxxxxxxx>
> ---
Makes sense.
Reviewed-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>
--
Kind regards,
Joshua Crofts