Patch "iio: adc: imx93: fix a signedness bug in imx93_adc_read_raw()" has been added to the 6.3-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: adc: imx93: fix a signedness bug in imx93_adc_read_raw()

to the 6.3-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-adc-imx93-fix-a-signedness-bug-in-imx93_adc_read.patch
and it can be found in the queue-6.3 subdirectory.

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



commit de6e8c113f6f1299a6d1e5a6649f33ed6d8b0853
Author: Dan Carpenter <error27@xxxxxxxxx>
Date:   Tue Feb 14 18:47:30 2023 +0300

    iio: adc: imx93: fix a signedness bug in imx93_adc_read_raw()
    
    [ Upstream commit 20f291b88ecf23f674ee2ed980a4d93b7f16a06f ]
    
    The problem is these lines:
    
            ret = vref_uv = regulator_get_voltage(adc->vref);
            if (ret < 0)
    
    The "ret" variable is type long and "vref_uv" is u32 so that means
    the condition can never be true on a 64bit system.  A negative error
    code from regulator_get_voltage() would be cast to a high positive
    u32 value and then remain a high positive value when cast to a long.
    
    The "ret" variable only ever stores ints so it should be declared as
    an int.  We can delete the "vref_uv" variable and use "ret" directly.
    
    Fixes: 7d02296ac8b8 ("iio: adc: add imx93 adc support")
    Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>
    Reviewed-by: Haibo Chen <haibo.chen@xxxxxxx>
    Link: https://lore.kernel.org/r/Y+utEvjfjQRQo2QB@kili
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/iio/adc/imx93_adc.c b/drivers/iio/adc/imx93_adc.c
index a775d2e405671..dce9ec91e4a77 100644
--- a/drivers/iio/adc/imx93_adc.c
+++ b/drivers/iio/adc/imx93_adc.c
@@ -236,8 +236,7 @@ static int imx93_adc_read_raw(struct iio_dev *indio_dev,
 {
 	struct imx93_adc *adc = iio_priv(indio_dev);
 	struct device *dev = adc->dev;
-	long ret;
-	u32 vref_uv;
+	int ret;
 
 	switch (mask) {
 	case IIO_CHAN_INFO_RAW:
@@ -253,10 +252,10 @@ static int imx93_adc_read_raw(struct iio_dev *indio_dev,
 		return IIO_VAL_INT;
 
 	case IIO_CHAN_INFO_SCALE:
-		ret = vref_uv = regulator_get_voltage(adc->vref);
+		ret = regulator_get_voltage(adc->vref);
 		if (ret < 0)
 			return ret;
-		*val = vref_uv / 1000;
+		*val = ret / 1000;
 		*val2 = 12;
 		return IIO_VAL_FRACTIONAL_LOG2;
 



[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