[PATCH] iio: dac: adi-axi-dac: add io_mode check

Angelo Dureghello posted 1 patch 10 months ago
drivers/iio/dac/adi-axi-dac.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] iio: dac: adi-axi-dac: add io_mode check
Posted by Angelo Dureghello 10 months ago
From: Angelo Dureghello <adureghello@baylibre.com>

Add safe check to the high bound of the enum values,

Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
 drivers/iio/dac/adi-axi-dac.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
index 009fb987e1afd04c3dbc59a9742f7982744420c2..892d770aec69c4259de777058801c9ab33c79923 100644
--- a/drivers/iio/dac/adi-axi-dac.c
+++ b/drivers/iio/dac/adi-axi-dac.c
@@ -728,6 +728,9 @@ static int axi_dac_bus_set_io_mode(struct iio_backend *back,
 	struct axi_dac_state *st = iio_backend_get_priv(back);
 	int ival, ret;
 
+	if (mode > AD3552R_IO_MODE_QSPI)
+		return -EINVAL;
+
 	guard(mutex)(&st->lock);
 
 	ret = regmap_update_bits(st->regmap, AXI_DAC_CUSTOM_CTRL_REG,

---
base-commit: 4dd0ce442fa57f5274878c89223362344f28224c
change-id: 20250219-wip-bl-axi-dac-add-enum-check-8bb617285793

Best regards,
-- 
Angelo Dureghello <adureghello@baylibre.com>
Re: [PATCH] iio: dac: adi-axi-dac: add io_mode check
Posted by Jonathan Cameron 9 months, 4 weeks ago
On Wed, 19 Feb 2025 19:57:43 +0100
Angelo Dureghello <adureghello@baylibre.com> wrote:

> From: Angelo Dureghello <adureghello@baylibre.com>
> 
> Add safe check to the high bound of the enum values,
> 
> Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
> ---
Applied. thanks!

Jonathan
>  drivers/iio/dac/adi-axi-dac.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
> index 009fb987e1afd04c3dbc59a9742f7982744420c2..892d770aec69c4259de777058801c9ab33c79923 100644
> --- a/drivers/iio/dac/adi-axi-dac.c
> +++ b/drivers/iio/dac/adi-axi-dac.c
> @@ -728,6 +728,9 @@ static int axi_dac_bus_set_io_mode(struct iio_backend *back,
>  	struct axi_dac_state *st = iio_backend_get_priv(back);
>  	int ival, ret;
>  
> +	if (mode > AD3552R_IO_MODE_QSPI)
> +		return -EINVAL;
> +
>  	guard(mutex)(&st->lock);
>  
>  	ret = regmap_update_bits(st->regmap, AXI_DAC_CUSTOM_CTRL_REG,
> 
> ---
> base-commit: 4dd0ce442fa57f5274878c89223362344f28224c
> change-id: 20250219-wip-bl-axi-dac-add-enum-check-8bb617285793
> 
> Best regards,