Skip to content

Commit 17fa2dc

Browse files
arndbjic23
authored andcommitted
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: 059c53b ("iio: adc: Add Renesas GyroADC driver") Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Marek Vasut <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 0f06feb commit 17fa2dc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/iio/adc/rcar-gyroadc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
336336
struct device_node *child;
337337
struct regulator *vref;
338338
unsigned int reg;
339-
unsigned int adcmode, childmode;
339+
unsigned int adcmode = -1, childmode;
340340
unsigned int sample_width;
341341
unsigned int num_channels;
342342
int ret, first = 1;
@@ -366,6 +366,8 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
366366
channels = rcar_gyroadc_iio_channels_3;
367367
num_channels = ARRAY_SIZE(rcar_gyroadc_iio_channels_3);
368368
break;
369+
default:
370+
return -EINVAL;
369371
}
370372

371373
/*

0 commit comments

Comments
 (0)