Skip to content

Commit 86a24e9

Browse files
Nikita Zhandarovichbroonie
authored andcommitted
ASoC: fsl_asrc_dma: fix potential null-ptr-deref
dma_request_slave_channel() may return NULL which will lead to NULL pointer dereference error in 'tmp_chan->private'. Correct this behaviour by, first, switching from deprecated function dma_request_slave_channel() to dma_request_chan(). Secondly, enable sanity check for the resuling value of dma_request_chan(). Also, fix description that follows the enacted changes and that concerns the use of dma_request_slave_channel(). Fixes: 706e2c8 ("ASoC: fsl_asrc_dma: Reuse the dma channel if available in Back-End") Co-developed-by: Natalia Petrova <[email protected]> Signed-off-by: Nikita Zhandarovich <[email protected]> Acked-by: Shengjiu Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 2387871 commit 86a24e9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sound/soc/fsl/fsl_asrc_dma.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,19 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
209209
be_chan = soc_component_to_pcm(component_be)->chan[substream->stream];
210210
tmp_chan = be_chan;
211211
}
212-
if (!tmp_chan)
213-
tmp_chan = dma_request_slave_channel(dev_be, tx ? "tx" : "rx");
212+
if (!tmp_chan) {
213+
tmp_chan = dma_request_chan(dev_be, tx ? "tx" : "rx");
214+
if (IS_ERR(tmp_chan)) {
215+
dev_err(dev, "failed to request DMA channel for Back-End\n");
216+
return -EINVAL;
217+
}
218+
}
214219

215220
/*
216221
* An EDMA DEV_TO_DEV channel is fixed and bound with DMA event of each
217222
* peripheral, unlike SDMA channel that is allocated dynamically. So no
218223
* need to configure dma_request and dma_request2, but get dma_chan of
219-
* Back-End device directly via dma_request_slave_channel.
224+
* Back-End device directly via dma_request_chan.
220225
*/
221226
if (!asrc->use_edma) {
222227
/* Get DMA request of Back-End */

0 commit comments

Comments
 (0)