]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ASoC: stm32: spdifrx: fix dma channel release in stm32_spdifrx_remove
authorAmelie Delaunay <amelie.delaunay@foss.st.com>
Tue, 5 Nov 2024 14:02:42 +0000 (15:02 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 5 Nov 2024 16:26:03 +0000 (16:26 +0000)
In case of error when requesting ctrl_chan DMA channel, ctrl_chan is not
null. So the release of the dma channel leads to the following issue:
[    4.879000] st,stm32-spdifrx 500d0000.audio-controller:
dma_request_slave_channel error -19
[    4.888975] Unable to handle kernel NULL pointer dereference
at virtual address 000000000000003d
[...]
[    5.096577] Call trace:
[    5.099099]  dma_release_channel+0x24/0x100
[    5.103235]  stm32_spdifrx_remove+0x24/0x60 [snd_soc_stm32_spdifrx]
[    5.109494]  stm32_spdifrx_probe+0x320/0x4c4 [snd_soc_stm32_spdifrx]

To avoid this issue, release channel only if the pointer is valid.

Fixes: 794df9448edb ("ASoC: stm32: spdifrx: manage rebind issue")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Link: https://patch.msgid.link/20241105140242.527279-1-olivier.moysan@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/stm/stm32_spdifrx.c

index d1b32ba1e1a210baa91dfd81c75140798442ae6b..9e30852de93cdf471da1f6b02fa0b2ba60384c44 100644 (file)
@@ -939,7 +939,7 @@ static void stm32_spdifrx_remove(struct platform_device *pdev)
 {
        struct stm32_spdifrx_data *spdifrx = platform_get_drvdata(pdev);
 
-       if (spdifrx->ctrl_chan)
+       if (!IS_ERR(spdifrx->ctrl_chan))
                dma_release_channel(spdifrx->ctrl_chan);
 
        if (spdifrx->dmab)