From 04ee034f4b322e88af93660ace9e4bd9fef736dc Mon Sep 17 00:00:00 2001 From: Thomas Stranger Date: Thu, 15 Apr 2021 12:37:09 +0200 Subject: [PATCH] drivers/dma: stm32 fix dmamux request id valid check The request id is given by the DMA request MUX id which start at offset 1 and are vaid until req_nb + gen_nb. Signed-off-by: Thomas Stranger --- drivers/dma/dmamux_stm32.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dma/dmamux_stm32.c b/drivers/dma/dmamux_stm32.c index 79d76cfa3b6..8f2989ec1b9 100644 --- a/drivers/dma/dmamux_stm32.c +++ b/drivers/dma/dmamux_stm32.c @@ -94,8 +94,9 @@ int dmamux_stm32_configure(const struct device *dev, uint32_t id, */ int request_id = config->dma_slot; - if (request_id >= dev_config->req_nb + dev_config->gen_nb) { - LOG_ERR("request ID %d is too big.", request_id); + if (request_id == 0 || + request_id > dev_config->req_nb + dev_config->gen_nb) { + LOG_ERR("request ID %d is not valid.", request_id); return -EINVAL; }