diff mbox

[01/11] iio: sensors-core: st: Check st_sensors_set_drdy_int_pin()'s return value

Message ID 1409231657-18294-1-git-send-email-lee.jones@linaro.org
State Accepted
Commit 3c8bf223469b4db4d63e1dd8bdbde5ffb32d0cba
Headers show

Commit Message

Lee Jones Aug. 28, 2014, 1:14 p.m. UTC
Value from st_sensors_set_drdy_int_pin() is assigned to err here,
but that stored value is not used before it is overwritten.  To fix
this we're enforcing a check on st_sensors_set_drdy_int_pin()'s
return value and if it's an error, we're returning right away.

Cc: jic23@kernel.org
Cc: linux-iio@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/iio/common/st_sensors/st_sensors_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jonathan Cameron Aug. 30, 2014, 9:49 a.m. UTC | #1
On 28/08/14 14:14, Lee Jones wrote:
> Value from st_sensors_set_drdy_int_pin() is assigned to err here,
> but that stored value is not used before it is overwritten.  To fix
> this we're enforcing a check on st_sensors_set_drdy_int_pin()'s
> return value and if it's an error, we're returning right away.
> 
> Cc: jic23@kernel.org
> Cc: linux-iio@vger.kernel.org
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Applied to the togreg branch of iio.git

Thanks,

Jonathan
> ---
>  drivers/iio/common/st_sensors/st_sensors_core.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index 8a4ec00..24cfe4e 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -306,8 +306,11 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
>  	if (of_pdata)
>  		pdata = of_pdata;
>  
> -	if (pdata)
> +	if (pdata) {
>  		err = st_sensors_set_drdy_int_pin(indio_dev, pdata);
> +		if (err < 0)
> +			return err;
> +	}
>  
>  	err = st_sensors_set_enable(indio_dev, false);
>  	if (err < 0)
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
diff mbox

Patch

diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 8a4ec00..24cfe4e 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -306,8 +306,11 @@  int st_sensors_init_sensor(struct iio_dev *indio_dev,
 	if (of_pdata)
 		pdata = of_pdata;
 
-	if (pdata)
+	if (pdata) {
 		err = st_sensors_set_drdy_int_pin(indio_dev, pdata);
+		if (err < 0)
+			return err;
+	}
 
 	err = st_sensors_set_enable(indio_dev, false);
 	if (err < 0)