]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dmaengine: mcf-edma: Fix a potential un-allocated memory access
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Wed, 12 Jul 2023 12:56:45 +0000 (18:26 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Aug 2023 16:22:02 +0000 (18:22 +0200)
commit086a80eb62131940125eddd43b2fb1ed7d9ab806
tree4a9c1dd802445a45ae49213d6dd92cab13c696b1
parent7e1dc94b2d5089916840bf5b8a61063106713eda
dmaengine: mcf-edma: Fix a potential un-allocated memory access

commit 0a46781c89dece85386885a407244ca26e5c1c44 upstream.

When 'mcf_edma' is allocated, some space is allocated for a
flexible array at the end of the struct. 'chans' item are allocated, that is
to say 'pdata->dma_channels'.

Then, this number of item is stored in 'mcf_edma->n_chans'.

A few lines later, if 'mcf_edma->n_chans' is 0, then a default value of 64
is set.

This ends to no space allocated by devm_kzalloc() because chans was 0, but
64 items are read and/or written in some not allocated memory.

Change the logic to define a default value before allocating the memory.

Fixes: e7a3ff92eaf1 ("dmaengine: fsl-edma: add ColdFire mcf5441x edma support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/f55d914407c900828f6fad3ea5fa791a5f17b9a4.1685172449.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/dma/mcf-edma.c