diff mbox series

[v5,3/8] iio: adc: mp2629: fix potential array out of bound access

Message ID 20221029093000.45451-4-sravanhome@gmail.com (mailing list archive)
State Accepted
Headers show
Series Add support for mp2733 battery charger | expand

Commit Message

saravanan sekar Oct. 29, 2022, 9:29 a.m. UTC
Add sentinel at end of maps to avoid potential array out of
bound access in iio core.

Fixes: 7abd9fb6468 ("iio: adc: mp2629: Add support for mp2629 ADC driver")
Signed-off-by: Saravanan Sekar <sravanhome@gmail.com>
---
 drivers/iio/adc/mp2629_adc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jonathan Cameron Oct. 29, 2022, 12:30 p.m. UTC | #1
On Sat, 29 Oct 2022 11:29:55 +0200
Saravanan Sekar <sravanhome@gmail.com> wrote:

> Add sentinel at end of maps to avoid potential array out of
> bound access in iio core.
> 
> Fixes: 7abd9fb6468 ("iio: adc: mp2629: Add support for mp2629 ADC driver")
> Signed-off-by: Saravanan Sekar <sravanhome@gmail.com>
Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/mp2629_adc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c
> index f7af9af1665d..88e947f300cf 100644
> --- a/drivers/iio/adc/mp2629_adc.c
> +++ b/drivers/iio/adc/mp2629_adc.c
> @@ -57,7 +57,8 @@ static struct iio_map mp2629_adc_maps[] = {
>  	MP2629_MAP(SYSTEM_VOLT, "system-volt"),
>  	MP2629_MAP(INPUT_VOLT, "input-volt"),
>  	MP2629_MAP(BATT_CURRENT, "batt-current"),
> -	MP2629_MAP(INPUT_CURRENT, "input-current")
> +	MP2629_MAP(INPUT_CURRENT, "input-current"),
> +	{ }
>  };
>  
>  static int mp2629_read_raw(struct iio_dev *indio_dev,
diff mbox series

Patch

diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c
index f7af9af1665d..88e947f300cf 100644
--- a/drivers/iio/adc/mp2629_adc.c
+++ b/drivers/iio/adc/mp2629_adc.c
@@ -57,7 +57,8 @@  static struct iio_map mp2629_adc_maps[] = {
 	MP2629_MAP(SYSTEM_VOLT, "system-volt"),
 	MP2629_MAP(INPUT_VOLT, "input-volt"),
 	MP2629_MAP(BATT_CURRENT, "batt-current"),
-	MP2629_MAP(INPUT_CURRENT, "input-current")
+	MP2629_MAP(INPUT_CURRENT, "input-current"),
+	{ }
 };
 
 static int mp2629_read_raw(struct iio_dev *indio_dev,