blob: 49986e3b657e4c9dc8a17a1f921b1ccc7b6d6fce [file] [log] [blame]
From 1d0272792aeca824e55424e5b057602594c65b23 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <>
Date: Fri, 3 Feb 2017 18:01:23 +0100
Subject: [PATCH 113/255] iio: adc: handle unknow of_device_id data
If we get an unknown 'childmode' value, a number of variables are not
initialized properly:
drivers/iio/adc/rcar-gyroadc.c: In function 'rcar_gyroadc_probe':
drivers/iio/adc/rcar-gyroadc.c:390:5: error: 'num_channels' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/iio/adc/rcar-gyroadc.c:426:22: error: 'sample_width' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/iio/adc/rcar-gyroadc.c:428:23: error: 'channels' may be used uninitialized in this function [-Werror=maybe-uninitialized]
The driver is currently correct, but handling this properly is more robust
for possible modifications.
There is also a false-positive warning about adcmode being possibly uninitialized,
but that cannot happen as we also check the 'first' flag:
drivers/iio/adc/rcar-gyroadc.c:398:26: error: 'adcmode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
This adds an initialization for 'adcmode' and bails out for any unknown childmode.
Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
Signed-off-by: Arnd Bergmann <>
Acked-by: Marek Vasut <>
Signed-off-by: Jonathan Cameron <>
(cherry picked from commit 17fa2dcbd6325ab877651bef04fca9dd828a2758)
Signed-off-by: Simon Horman <>
drivers/iio/adc/rcar-gyroadc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/drivers/iio/adc/rcar-gyroadc.c
+++ b/drivers/iio/adc/rcar-gyroadc.c
@@ -336,7 +336,7 @@ static int rcar_gyroadc_parse_subdevs(st
struct device_node *child;
struct regulator *vref;
unsigned int reg;
- unsigned int adcmode, childmode;
+ unsigned int adcmode = -1, childmode;
unsigned int sample_width;
unsigned int num_channels;
int ret, first = 1;
@@ -366,6 +366,8 @@ static int rcar_gyroadc_parse_subdevs(st
channels = rcar_gyroadc_iio_channels_3;
num_channels = ARRAY_SIZE(rcar_gyroadc_iio_channels_3);
+ default:
+ return -EINVAL;