Skip to contentSkip to conversation

iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()

PATCH Applied Dan Carpenter 3 participants 3 messages Dec 15, 2021 – Dec 16, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()

The > needs to be >= to prevent accessing one element beyond the end of the st->channel_configs[] array.

Fixes fea251b6a5db ("iio: addac: add AD74413R driver")

---
Obligatory grumble: When you merge a new driver please use a patch prefix based on what the driver will use.

Bad: [SUBJECT] subsystem: add new driver for XYZ123
Good: [SUBJECT] subsystem/xyz123: add new driver for XYZ123

Same rule for adding subdirectories. That way no one (me) has to guess.

 drivers/iio/addac/ad74413r.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/addac/ad74413r.c +1 -1
index cbd9aa9b399a..289d254943e1 100644
@@ -1150,7 +1150,7 @@ static int ad74413r_parse_channel_config(struct iio_dev *indio_dev,
 		return ret;
 	}
 
-	if (index > AD74413R_CHANNEL_MAX) {
+	if (index >= AD74413R_CHANNEL_MAX) {
 		dev_err(st->dev, "Channel index %u is too large\n", index);
 		return -EINVAL;
 	}
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 45 lines

-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Wednesday, December 15, 2021 1:51 PM
To: Tanislav, Cosmin <[email protected]>
Cc: Hennerich, Michael <[email protected]>; Jonathan Cameron <[email protected]>; Linus Walleij <[email protected]>; linux- [email protected]; [email protected]
Subject: [PATCH] iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()

[External]

The > needs to be >= to prevent accessing one element beyond the end of the st->channel_configs[] array.

Fixes fea251b6a5db ("iio: addac: add AD74413R driver")

---
Obligatory grumble: When you merge a new driver please use a patch prefix based on what the driver will use.

Bad: [SUBJECT] subsystem: add new driver for XYZ123
Good: [SUBJECT] subsystem/xyz123: add new driver for XYZ123

Same rule for adding subdirectories. That way no one (me) has to guess.

 drivers/iio/addac/ad74413r.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/addac/ad74413r.c +1 -1
index cbd9aa9b399a..289d254943e1 100644
@@ -1150,7 +1150,7 @@ static int ad74413r_parse_channel_config(struct
 iio_dev *indio_dev,
 		return ret;
 	}
 
-	if (index > AD74413R_CHANNEL_MAX) {
+	if (index >= AD74413R_CHANNEL_MAX) {
 		dev_err(st->dev, "Channel index %u is too large\n", index);
 		return -EINVAL;

}
--
2.20.1

#2 lore raw
Quoted 1 line · Cosmin

Applied, thanks,

Jonathan

Quoted 47 lines
Quoted 46 lines

-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Wednesday, December 15, 2021 1:51 PM
To: Tanislav, Cosmin <[email protected]>
Cc: Hennerich, Michael <[email protected]>; Jonathan Cameron <[email protected]>; Linus Walleij <[email protected]>; linux- [email protected]; [email protected]
Subject: [PATCH] iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()

[External]

The > needs to be >= to prevent accessing one element beyond the end of the st->channel_configs[] array.

Fixes fea251b6a5db ("iio: addac: add AD74413R driver")

---
Obligatory grumble: When you merge a new driver please use a patch prefix based on what the driver will use.

Bad: [SUBJECT] subsystem: add new driver for XYZ123
Good: [SUBJECT] subsystem/xyz123: add new driver for XYZ123

Same rule for adding subdirectories. That way no one (me) has to guess.

 drivers/iio/addac/ad74413r.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/addac/ad74413r.c +1 -1
index cbd9aa9b399a..289d254943e1 100644
@@ -1150,7 +1150,7 @@ static int ad74413r_parse_channel_config(struct
 iio_dev *indio_dev,
 		return ret;
 	}
 
-	if (index > AD74413R_CHANNEL_MAX) {
+	if (index >= AD74413R_CHANNEL_MAX) {
 		dev_err(st->dev, "Channel index %u is too large\n", index);
 		return -EINVAL;

}
--
2.20.1