<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 17, 2023 at 9:33 PM Nikita Zhandarovich <<a href="mailto:n.zhandarovich@fintech.ru">n.zhandarovich@fintech.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">dma_request_slave_channel() may return NULL which will lead to<br>
NULL pointer dereference error in 'tmp_chan->private'.<br>
<br>
Correct this behaviour by, first, switching from deprecated function<br>
dma_request_slave_channel() to dma_request_chan(). Secondly, enable<br>
sanity check for the resuling value of dma_request_chan().<br>
Also, fix description that follows the enacted changes and that<br>
concerns the use of dma_request_slave_channel().<br>
<br>
Fixes: 706e2c881158 ("ASoC: fsl_asrc_dma: Reuse the dma channel if available in Back-End")<br>
Co-developed-by: Natalia Petrova <<a href="mailto:n.petrova@fintech.ru" target="_blank">n.petrova@fintech.ru</a>><br>
Signed-off-by: Nikita Zhandarovich <<a href="mailto:n.zhandarovich@fintech.ru" target="_blank">n.zhandarovich@fintech.ru</a>><br></blockquote><div><br></div><div>Acked-by: Shengjiu Wang <<a href="mailto:shengjiu.wang@gmail.com">shengjiu.wang@gmail.com</a>></div><div><br></div><div>Best regards</div><div>wang shengjiu </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
 sound/soc/fsl/fsl_asrc_dma.c | 11 ++++++++---<br>
 1 file changed, 8 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c<br>
index 3b81a465814a..05a7d1588d20 100644<br>
--- a/sound/soc/fsl/fsl_asrc_dma.c<br>
+++ b/sound/soc/fsl/fsl_asrc_dma.c<br>
@@ -209,14 +209,19 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,<br>
                be_chan = soc_component_to_pcm(component_be)->chan[substream->stream];<br>
                tmp_chan = be_chan;<br>
        }<br>
-       if (!tmp_chan)<br>
-               tmp_chan = dma_request_slave_channel(dev_be, tx ? "tx" : "rx");<br>
+       if (!tmp_chan) {<br>
+               tmp_chan = dma_request_chan(dev_be, tx ? "tx" : "rx");<br>
+               if (IS_ERR(tmp_chan)) {<br>
+                       dev_err(dev, "failed to request DMA channel for Back-End\n");<br>
+                       return -EINVAL;<br>
+               }<br>
+       }<br>
<br>
        /*<br>
         * An EDMA DEV_TO_DEV channel is fixed and bound with DMA event of each<br>
         * peripheral, unlike SDMA channel that is allocated dynamically. So no<br>
         * need to configure dma_request and dma_request2, but get dma_chan of<br>
-        * Back-End device directly via dma_request_slave_channel.<br>
+        * Back-End device directly via dma_request_chan.<br>
         */<br>
        if (!asrc->use_edma) {<br>
                /* Get DMA request of Back-End */<br>
</blockquote></div></div>