Patch "iio: addac: stx104: Fix race condition when converting analog-to-digital" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    iio: addac: stx104: Fix race condition when converting analog-to-digital

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     iio-addac-stx104-fix-race-condition-when-converting-.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 026ba2fd0ed8ecf992b77ab9abfdd0d47f6e805a
Author: William Breathitt Gray <william.gray@xxxxxxxxxx>
Date:   Thu Apr 6 10:40:11 2023 -0400

    iio: addac: stx104: Fix race condition when converting analog-to-digital
    
    [ Upstream commit 4f9b80aefb9e2f542a49d9ec087cf5919730e1dd ]
    
    The ADC conversion procedure requires several device I/O operations
    performed in a particular sequence. If stx104_read_raw() is called
    concurrently, the ADC conversion procedure could be clobbered. Prevent
    such a race condition by utilizing a mutex.
    
    Fixes: 4075a283ae83 ("iio: stx104: Add IIO support for the ADC channels")
    Signed-off-by: William Breathitt Gray <william.gray@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/2ae5e40eed5006ca735e4c12181a9ff5ced65547.1680790580.git.william.gray@xxxxxxxxxx
    Cc: <Stable@xxxxxxxxxxxxxxx>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c
index e110a910235ff..b658a75d4e3a8 100644
--- a/drivers/iio/adc/stx104.c
+++ b/drivers/iio/adc/stx104.c
@@ -117,6 +117,8 @@ static int stx104_read_raw(struct iio_dev *indio_dev,
 			return IIO_VAL_INT;
 		}
 
+		mutex_lock(&priv->lock);
+
 		/* select ADC channel */
 		iowrite8(chan->channel | (chan->channel << 4), &reg->achan);
 
@@ -127,6 +129,8 @@ static int stx104_read_raw(struct iio_dev *indio_dev,
 		while (ioread8(&reg->cir_asr) & BIT(7));
 
 		*val = ioread16(&reg->ssr_ad);
+
+		mutex_unlock(&priv->lock);
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_OFFSET:
 		/* get ADC bipolar/unipolar configuration */



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux