ASoC et alia: Convert to use dma_request_chan()
cover ASoC et alia: Convert to use dma_request_chan()
Convert the last users (mostly in ASoC) to use dma_request_chan() and drop deprecated dma_request_slave_channel() completely.
I think the best is to allow Mark to take the whole lot and provide an immutable tag or branch to others (DMAengine and GPIB).
Andy Shevchenko (7):
ASoC: stm32: spdifrx: Drop mention of the deprecated and unused call
ASoC: sprd: Replace dma_request_slave_channel() by dma_request_chan()
ASoC: soc-generic-dmaengine-pcm: Replace dma_request_slave_channel()
by dma_request_chan()
ASoC: pxa: Replace dma_request_slave_channel() by dma_request_chan()
ASoC: fsl_asrc: Replace dma_request_slave_channel() by
dma_request_chan()
gpib: fmh_gpib: Replace dma_request_slave_channel() by
dma_request_chan()
dmaengine: Remove deprecated dma_request_slave_channel()
drivers/gpib/fmh_gpib/fmh_gpib.c | 7 ++++--- include/linux/dmaengine.h | 9 --------- sound/soc/fsl/fsl_asrc.c | 2 +- sound/soc/fsl/fsl_asrc_dma.c | 13 +++++++------ sound/soc/fsl/fsl_asrc_m2m.c | 8 ++++---- sound/soc/fsl/fsl_easrc.c | 2 +- sound/soc/pxa/pxa2xx-pcm-lib.c | 10 +++++++--- sound/soc/soc-generic-dmaengine-pcm.c | 8 +++++--- sound/soc/sprd/sprd-pcm-compress.c | 7 +++---- sound/soc/sprd/sprd-pcm-dma.c | 7 +++---- sound/soc/stm/stm32_spdifrx.c | 2 +- 11 files changed, 36 insertions(+), 39 deletions(-)
Signature · 1 line
2.50.1
PATCH 1/7 ASoC: stm32: spdifrx: Drop mention of the deprecated and unused call
The error message was not updated while driver moved from the deprecated dma_request_slave_channel() to the dma_request_chan(). Update the message by replacing it with the correct function.
--- sound/soc/stm/stm32_spdifrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/stm/stm32_spdifrx.c +1 -1
@@ -400,7 +400,7 @@ static int stm32_spdifrx_dma_ctrl_register(struct device *dev, spdifrx->ctrl_chan =dma_request_chan (dev,"rx-ctrl" );if (IS_ERR (spdifrx->ctrl_chan))return dev_err_probe (dev,PTR_ERR (spdifrx->ctrl_chan), -"dma_request_slave_channel error\n" ); +"dma_request_chan error\n" ); spdifrx->dmab =devm_kzalloc (dev,sizeof (struct snd_dma_buffer ),GFP_KERNEL );
Signature · 1 line
2.50.1
PATCH 2/7 ASoC: sprd: Replace dma_request_slave_channel() by dma_request_chan()
In reply to Andy ShevchenkoReplace dma_request_slave_channel() by dma_request_chan() as suggested since the former is deprecated.
--- sound/soc/sprd/sprd-pcm-compress.c | 7 +++---- sound/soc/sprd/sprd-pcm-dma.c | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-)
sound/soc/sprd/sprd-pcm-compress.c +3 -4
@@ -153,11 +153,10 @@ static int sprd_platform_compr_dma_config(struct snd_soc_component *component,return -EINVAL ; } - dma->chan =dma_request_slave_channel (dev, - dma_params->chan_name[channel]); -if (!dma->chan) { + dma->chan =dma_request_chan (dev, dma_params->chan_name[channel]); +if (IS_ERR (dma->chan)) {dev_err (dev,"failed to request dma channel\n" ); -return -ENODEV ; +return PTR_ERR (dma->chan); } sgt = sg =kzalloc_objs (*sg, sg_num);
sound/soc/sprd/sprd-pcm-dma.c +3 -4
@@ -171,13 +171,12 @@ static int sprd_pcm_request_dma_channel(struct snd_soc_component *component,for (i =0 ; i < channels; i++) {struct sprd_pcm_dma_data *data = &dma_private->data[i]; - data->chan =dma_request_slave_channel (dev, - dma_params->chan_name[i]); -if (!data->chan) { + data->chan =dma_request_chan (dev, dma_params->chan_name[i]); +if (IS_ERR (data->chan)) {dev_err (dev,"failed to request dma channel:%s\n" , dma_params->chan_name[i]);sprd_pcm_release_dma_channel (substream); -return -ENODEV ; +return PTR_ERR (data->chan); } }
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH v1 2/7] ASoC: sprd: Replace dma_request_slave_channel() by dma_request_chan()
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] ASoC: sprd: crash in dma_release_channel() due to ERR_PTR leak --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ASoC: sprd: crash in dma_release_channel() due to ERR_PTR leak
--
commit 5e4c398ebe4c03b68c30e555198977e4ad4905e4
Author: Andy Shevchenko <[email protected]>
ASoC: sprd: Replace dma_request_slave_channel() by dma_request_chan()
This commit replaces deprecated dma_request_slave_channel calls with dma_request_chan. It updates the error checking from NULL checks to IS_ERR.
sound/soc/sprd/sprd-pcm-compress.c static int sprd_platform_compr_dma_config(struct snd_soc_component *component, · line 157
Quoted 13 lines
sound/soc/sprd/sprd-pcm-compress.c +2
-3@@ -153,11 +153,10 @@ static int sprd_platform_compr_dma_config(struct snd_soc_component *component,return -EINVAL ; } - dma->chan =dma_request_slave_channel (dev, - dma_params->chan_name[channel]); -if (!dma->chan) { + dma->chan =dma_request_chan (dev, dma_params->chan_name[channel]); +if (IS_ERR (dma->chan)) {
[Severity: High]
If dma_request_chan fails, does this leak the error pointer into the compress stream's persistent dma array?
When the file descriptor is closed or cleaned up, the free path in sprd_platform_compr_free() will attempt to release the channel:
if (dma->chan) {
dma_release_channel(dma->chan);
dma->chan = NULL;
}Since the error path doesn't clear the error pointer from dma->chan, the if check evaluates to true. Will dma_release_channel() then dereference the error pointer and crash?
Quoted 11 lines
sound/soc/sprd/sprd-pcm-compress.c +1
-1dev_err (dev,"failed to request dma channel\n" ); -return -ENODEV ; +return PTR_ERR (dma->chan); } sgt = sg =kzalloc_objs (*sg, sg_num);sound/soc/sprd/sprd-pcm-dma.c +0
-0
sound/soc/sprd/sprd-pcm-dma.c static int sprd_pcm_request_dma_channel(struct snd_soc_component *component, · line 175
Quoted 8 lines
sound/soc/sprd/sprd-pcm-dma.c +2
-3@@ -171,13 +171,12 @@ static int sprd_pcm_request_dma_channel(struct snd_soc_component *component,for (i =0 ; i < channels; i++) {struct sprd_pcm_dma_data *data = &dma_private->data[i]; - data->chan =dma_request_slave_channel (dev, - dma_params->chan_name[i]); -if (!data->chan) { + data->chan =dma_request_chan (dev, dma_params->chan_name[i]); +if (IS_ERR (data->chan)) {
[Severity: High]
By directly assigning the return value here, does the error pointer become visible to the cleanup function on failure?
When dma_request_chan fails, sprd_pcm_release_dma_channel() is called immediately below. That function loops through the channels and checks:
if (data->chan) {
dma_release_channel(data->chan);
}This condition evaluates to true for an error pointer, blindly passing it to dma_release_channel. Could this lead to a kernel panic when the invalid pointer is dereferenced?
Quoted 8 lines
sound/soc/sprd/sprd-pcm-dma.c +1
-1dev_err (dev,"failed to request dma channel:%s\n" , dma_params->chan_name[i]);sprd_pcm_release_dma_channel (substream); -return -ENODEV ; +return PTR_ERR (data->chan); } }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v1 2/7] ASoC: sprd: Replace dma_request_slave_channel() by dma_request_chan()
Quoted 39 lines · On Tue, Sep 15, 2026 at 10:19:24AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ASoC: sprd: crash indma_release_channel()due toERR_PTRleak
--commit
5e4c398ebe4c03b68c30e555198977e4ad4905e4
Author: Andy Shevchenko <[email protected]>ASoC: sprd: Replace
dma_request_slave_channel()bydma_request_chan()This commit replaces deprecated
dma_request_slave_channelcalls withdma_request_chan. It updates the error checking from NULL checks toIS_ERR.sound/soc/sprd/sprd-pcm-compress.c static int sprd_platform_compr_dma_config(struct snd_soc_component *component, · line 157
Quoted 13 lines
sound/soc/sprd/sprd-pcm-compress.c +2
-3@@ -153,11 +153,10 @@ static int sprd_platform_compr_dma_config(struct snd_soc_component *component,return -EINVAL ; } - dma->chan =dma_request_slave_channel (dev, - dma_params->chan_name[channel]); -if (!dma->chan) { + dma->chan =dma_request_chan (dev, dma_params->chan_name[channel]); +if (IS_ERR (dma->chan)) {[Severity: High]
Ifdma_request_chanfails, does this leak the error pointer into the compress stream's persistent dma array?When the file descriptor is closed or cleaned up, the free path in
sprd_platform_compr_free()will attempt to release the channel:if (dma->chan) { dma_release_channel(dma->chan); dma->chan = NULL; }
Quoted 8 lines
Since the error path doesn't clear the error pointer from
dma->chan, the if check evaluates to true. Willdma_release_channel()then dereference the error pointer and crash?sound/soc/sprd/sprd-pcm-compress.c static int sprd_platform_compr_dma_config(struct snd_soc_component *component, · line 160
Quoted 4 lines
sound/soc/sprd/sprd-pcm-compress.c +1
-1dev_err (dev,"failed to request dma channel\n" ); -return -ENODEV ; +return PTR_ERR (dma->chan); }
Granted, I will add an amendment to dma_release_chan() to be NULL and ERR_PTR aware.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 2/7] ASoC: sprd: Replace dma_request_slave_channel() by dma_request_chan()
In reply to Andy ShevchenkoQuoted 5 lines · Andy Shevchenko
Replace
dma_request_slave_channel()bydma_request_chan()as suggested since the former is deprecated.Signed-off-by Andy Shevchenko <[email protected]>---
LGTM. Thanks.
Mark Brown
maintainerRe: [PATCH v1 2/7] ASoC: sprd: Replace dma_request_slave_channel() by dma_request_chan()
In reply to Andy ShevchenkoQuoted 7 lines · Andy Shevchenko
Replace
dma_request_slave_channel()bydma_request_chan()as suggested since the former is deprecated.sound/soc/sprd/sprd-pcm-dma.c +0
-0@@ -171,13 +171,12 @@ static int sprd_pcm_request_dma_channel(struct snd_soc_component *component,for (i =0 ; i < channels; i++) {struct sprd_pcm_dma_data *data = &dma_private->data[i];
sound/soc/sprd/sprd-pcm-dma.c static int sprd_pcm_request_dma_channel(struct snd_soc_component *component, · line 179
Quoted 10 lines
sound/soc/sprd/sprd-pcm-dma.c +3
-4- data->chan =dma_request_slave_channel (dev, - dma_params->chan_name[i]); -if (!data->chan) { + data->chan =dma_request_chan (dev, dma_params->chan_name[i]); +if (IS_ERR (data->chan)) {dev_err (dev,"failed to request dma channel:%s\n" , dma_params->chan_name[i]);sprd_pcm_release_dma_channel (substream); -return -ENODEV ; +return PTR_ERR (data->chan);
sprd_pcm_release_dma_channel() does:
if (data->chan) {
dma_release_channel(data->chan);
data->chan = NULL;so this won't DTRT with propagating the return code.
PATCH 3/7 ASoC: soc-generic-dmaengine-pcm: Replace dma_request_slave_channel() by dma_request_chan()
In reply to Andy ShevchenkoReplace dma_request_slave_channel() by dma_request_chan() as suggested since the former is deprecated.
--- sound/soc/soc-generic-dmaengine-pcm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/soc/soc-generic-dmaengine-pcm.c +5 -3
@@ -242,9 +242,11 @@ static int dmaengine_pcm_new(struct snd_soc_component *component,if (!substream)continue ; -if (!pcm->chan[i] && config->chan_names[i]) - pcm->chan[i] =dma_request_slave_channel (dev, - config->chan_names[i]); +if (!pcm->chan[i] && config->chan_names[i]) { + pcm->chan[i] =dma_request_chan (dev, config->chan_names[i]); +if (IS_ERR (pcm->chan[i])) + pcm->chan[i] =NULL ; + }if (!pcm->chan[i] && (pcm->flags &SND_DMAENGINE_PCM_FLAG_COMPAT )) { pcm->chan[i] = dmaengine_pcm_compat_request_channel(
Signature · 1 line
2.50.1
Re: [PATCH v1 3/7] ASoC: soc-generic-dmaengine-pcm: Replace dma_request_slave_channel() by dma_request_chan()
Quoted 17 lines · Andy Shevchenko
Replace
dma_request_slave_channel()bydma_request_chan()as suggested since the former is deprecated.Signed-off-by Andy Shevchenko <[email protected]>--- sound/soc/soc-generic-dmaengine-pcm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)sound/soc/soc-generic-dmaengine-pcm.c +0
-1@@ -242,9 +242,11 @@ static int dmaengine_pcm_new(struct snd_soc_component *component,if (!substream)continue ; -if (!pcm->chan[i] && config->chan_names[i])
sound/soc/soc-generic-dmaengine-pcm.c static int dmaengine_pcm_new(struct snd_soc_component *component, · line 252
Quoted 10 lines
sound/soc/soc-generic-dmaengine-pcm.c +5
-2- pcm->chan[i] =dma_request_slave_channel (dev, - config->chan_names[i]); +if (!pcm->chan[i] && config->chan_names[i]) { + pcm->chan[i] =dma_request_chan (dev, config->chan_names[i]); +if (IS_ERR (pcm->chan[i])) + pcm->chan[i] =NULL ; + }if (!pcm->chan[i] && (pcm->flags &SND_DMAENGINE_PCM_FLAG_COMPAT )) { pcm->chan[i] = dmaengine_pcm_compat_request_channel(
PATCH 4/7 ASoC: pxa: Replace dma_request_slave_channel() by dma_request_chan()
In reply to Andy ShevchenkoReplace dma_request_slave_channel() by dma_request_chan() as suggested since the former is deprecated.
--- sound/soc/pxa/pxa2xx-pcm-lib.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/pxa/pxa2xx-pcm-lib.c +7 -3
@@ -79,6 +79,7 @@ static int pxa2xx_pcm_open(struct snd_pcm_substream *substream)struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);struct snd_pcm_runtime *runtime = substream->runtime;struct snd_dmaengine_dai_dma_data *dma_params; +struct dma_chan *chan;int ret; runtime->hw = pxa2xx_pcm_hardware;
@@ -107,9 +108,12 @@ static int pxa2xx_pcm_open(struct snd_pcm_substream *substream)if (ret <0 )return ret; -return snd_dmaengine_pcm_open ( - substream,dma_request_slave_channel (snd_soc_rtd_to_cpu (rtd,0 )->dev, - dma_params->chan_name)); + chan =dma_request_chan (snd_soc_rtd_to_cpu (rtd,0 )->dev, dma_params->chan_name); + ret =PTR_ERR_OR_ZERO (chan); +if (ret) +return ret; + +return snd_dmaengine_pcm_open (substream, chan); }static int pxa2xx_pcm_close (struct snd_pcm_substream *substream)
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH v1 4/7] ASoC: pxa: Replace dma_request_slave_channel() by dma_request_chan()
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] UAPI: -EPROBE_DEFER leaked to user-space open() via pxa2xx_pcm_open() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] UAPI: -EPROBE_DEFER leaked to user-space open() via pxa2xx_pcm_open() --
commit 44587eacc45895505692b413ada6ab4975034283
Author: Andy Shevchenko <[email protected]>
ASoC: pxa: Replace dma_request_slave_channel() by dma_request_chan()
This commit replaces the deprecated dma_request_slave_channel() with dma_request_chan().
Quoted 4 lines
sound/soc/pxa/pxa2xx-pcm-lib.c +0
-0
[ ... ]
sound/soc/pxa/pxa2xx-pcm-lib.c static int pxa2xx_pcm_open(struct snd_pcm_substream *substream) · line 114
Quoted 11 lines
sound/soc/pxa/pxa2xx-pcm-lib.c +4
-3@@ -107,9 +108,12 @@ static int pxa2xx_pcm_open(struct snd_pcm_substream *substream)if (ret <0 )return ret; -return snd_dmaengine_pcm_open ( - substream,dma_request_slave_channel (snd_soc_rtd_to_cpu (rtd,0 )->dev, - dma_params->chan_name)); + chan =dma_request_chan (snd_soc_rtd_to_cpu (rtd,0 )->dev, dma_params->chan_name); + ret =PTR_ERR_OR_ZERO (chan); +if (ret) +return ret;
[Severity: Medium]
Will this leak the kernel-internal -EPROBE_DEFER error code to user-space?
If dma_request_chan() fails because the DMA driver isn't loaded yet, it can return -EPROBE_DEFER. Since pxa2xx_pcm_open() returns this directly, the -EPROBE_DEFER error code would be passed up to snd_pcm_open() and returned to the user-space application calling open() on the ALSA device.
In the old code, dma_request_slave_channel() returned NULL on failure, and snd_dmaengine_pcm_open() mapped that NULL to -ENXIO. Could we map the error here to a standard user-facing error like -ENXIO when dma_request_chan() fails?
Quoted 5 lines
sound/soc/pxa/pxa2xx-pcm-lib.c +2
-0+ +return snd_dmaengine_pcm_open (substream, chan); }static int pxa2xx_pcm_close (struct snd_pcm_substream *substream)
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH v1 4/7] ASoC: pxa: Replace dma_request_slave_channel() by dma_request_chan()
Quoted 3 lines · On Tue, Sep 15, 2026 at 10:21:28AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] UAPI: -EPROBE_DEFER leaked to user-spaceopen()viapxa2xx_pcm_open()--
[ ... ]
Quoted 16 lines
sound/soc/pxa/pxa2xx-pcm-lib.c static int pxa2xx_pcm_open(struct snd_pcm_substream *substream) · line 114
Quoted 7 lines
sound/soc/pxa/pxa2xx-pcm-lib.c +4
-3-return snd_dmaengine_pcm_open ( - substream,dma_request_slave_channel (snd_soc_rtd_to_cpu (rtd,0 )->dev, - dma_params->chan_name)); + chan =dma_request_chan (snd_soc_rtd_to_cpu (rtd,0 )->dev, dma_params->chan_name); + ret =PTR_ERR_OR_ZERO (chan); +if (ret) +return ret;[Severity: Medium]
Will this leak the kernel-internal -EPROBE_DEFER error code to user-space?If
dma_request_chan()fails because the DMA driver isn't loaded yet, it can return -EPROBE_DEFER. Sincepxa2xx_pcm_open()returns this directly, the -EPROBE_DEFER error code would be passed up tosnd_pcm_open()and returned to the user-space application callingopen()on the ALSA device.
Quoted 4 lines
In the old code,
dma_request_slave_channel()returned NULL on failure, andsnd_dmaengine_pcm_open()mapped that NULL to-ENXIO. Could we map the error here to a standard user-facing error like-ENXIOwhendma_request_chan()fails?
Sure, makes sense.
Quoted 1 line
Quoted 1 line
sound/soc/pxa/pxa2xx-pcm-lib.c +1
-0+return snd_dmaengine_pcm_open (substream, chan);
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 5/7 ASoC: fsl_asrc: Replace dma_request_slave_channel() by dma_request_chan()
In reply to Andy ShevchenkoReplace dma_request_slave_channel() by dma_request_chan() as suggested since the former is deprecated.
--- sound/soc/fsl/fsl_asrc.c | 2 +- sound/soc/fsl/fsl_asrc_dma.c | 13 +++++++------ sound/soc/fsl/fsl_asrc_m2m.c | 8 ++++---- sound/soc/fsl/fsl_easrc.c | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-)
sound/soc/fsl/fsl_asrc.c +1 -1
@@ -638,7 +638,7 @@ static struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair,sprintf (name,"%cx%c" , dir ==IN ?'r' :'t' , index +'a' ); -return dma_request_slave_channel (&asrc->pdev->dev, name); +return dma_request_chan (&asrc->pdev->dev, name); } static int fsl_asrc_dai_startup(struct snd_pcm_substream *substream,
sound/soc/fsl/fsl_asrc_dma.c +7 -6
@@ -191,9 +191,10 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, dma_params_fe->maxburst = dma_params_be->maxburst; pair->dma_chan[!dir] = asrc->get_dma_channel (pair, !dir); -if (!pair->dma_chan[!dir]) { + ret =PTR_ERR_OR_ZERO (pair->dma_chan[!dir]); +if (ret) {dev_err (dev,"failed to request DMA channel\n" ); -return -EINVAL ; +return ret; } ret =snd_dmaengine_pcm_prepare_slave_config (substream, params, &config_fe);
@@ -404,9 +405,9 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component,/* Request a dummy dma channel, which will be released later. */ tmp_chan = asrc->get_dma_channel (pair, dir); -if (!tmp_chan) { + ret =PTR_ERR_OR_ZERO (tmp_chan); +if (ret) {dev_err (dev,"failed to get dma channel\n" ); - ret = -EINVAL ; goto dma_chan_err; }
@@ -497,9 +498,9 @@ static int fsl_asrc_dma_pcm_new(struct snd_soc_component *component,/* Request a dma channel, which will be released later. */ chan = asrc->get_dma_channel (pair,IN ); -if (!chan) { + ret =PTR_ERR_OR_ZERO (chan); +if (ret) {dev_err (dev,"failed to get dma channel\n" ); - ret = -EINVAL ; goto dma_chan_err; }
sound/soc/fsl/fsl_asrc_m2m.c +4 -4
@@ -503,16 +503,16 @@ static int fsl_asrc_m2m_comp_task_create(struct snd_compr_stream *stream,/* Request dma channels */ pair->dma_chan[IN ] = asrc->get_dma_channel (pair,IN ); -if (!pair->dma_chan[IN ]) { + ret =PTR_ERR_OR_ZERO (pair->dma_chan[IN ]); +if (ret) {dev_err (dev,"[ctx%d] failed to get input DMA channel\n" , pair->index); - ret = -EBUSY ; goto err_dma_channel_in; } pair->dma_chan[OUT ] = asrc->get_dma_channel (pair,OUT ); -if (!pair->dma_chan[OUT ]) { + ret =PTR_ERR_OR_ZERO (pair->dma_chan[OUT ]); +if (ret) {dev_err (dev,"[ctx%d] failed to get output DMA channel\n" , pair->index); - ret = -EBUSY ; goto err_dma_channel_out; }
sound/soc/fsl/fsl_easrc.c +1 -1
@@ -1433,7 +1433,7 @@ static struct dma_chan *fsl_easrc_get_dma_channel(struct fsl_asrc_pair *ctx,/* Example of dma name: ctx0_rx */ sprintf (name,"ctx%c_%cx" , index +'0' , dir ==IN ?'r' :'t' ); -return dma_request_slave_channel (&easrc->pdev->dev, name); +return dma_request_chan (&easrc->pdev->dev, name); };static const unsigned int easrc_rates[] = {
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH v1 5/7] ASoC: fsl_asrc: Replace dma_request_slave_channel() by dma_request_chan()
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] sound: fsl_asrc: dma_release_channel() dereferences ERR_PTR in fsl_asrc_dma_hw_free --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] sound: fsl_asrc: dma_release_channel() dereferences ERR_PTR in fsl_asrc_dma_hw_free --
commit 6b21fbae024779272022d29e64403ad02a43c0a2
Author: Andy Shevchenko <[email protected]>
Subject: ASoC: fsl_asrc: Replace dma_request_slave_channel() by dma_request_chan()
This patch replaces the deprecated dma_request_slave_channel() API with dma_request_chan() across the fsl_asrc driver.
Quoted 5 lines
sound/soc/fsl/fsl_asrc_dma.c +0
-0
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 198
Quoted 10 lines
sound/soc/fsl/fsl_asrc_dma.c +3
-2@@ -191,9 +191,10 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, dma_params_fe->maxburst = dma_params_be->maxburst; pair->dma_chan[!dir] = asrc->get_dma_channel (pair, !dir); -if (!pair->dma_chan[!dir]) { + ret =PTR_ERR_OR_ZERO (pair->dma_chan[!dir]); +if (ret) {dev_err (dev,"failed to request DMA channel\n" ); -return -EINVAL ; +return ret; }
[Severity: High]
Will this cause a panic in fsl_asrc_dma_hw_free() if get_dma_channel() fails?
Since dma_request_chan() returns an ERR_PTR on failure, pair->dma_chan[!dir] will now store an ERR_PTR instead of NULL when the DMA channel request fails.
If hw_params fails here, the ALSA PCM core handles the failure by invoking the component's hw_free callback to clean up partially allocated resources. That function checks if the channel pointer is truthy:
sound/soc/fsl/fsl_asrc_dma.c:fsl_asrc_dma_hw_free() {
...
if (pair->dma_chan[!dir])
dma_release_channel(pair->dma_chan[!dir]);
...
}Since an ERR_PTR evaluates to true, dma_release_channel() is called with the ERR_PTR, which will cause an invalid memory access and an immediate kernel panic when it attempts to read chan->client_count.
Does fsl_asrc_dma_hw_free() need to be updated to use IS_ERR_OR_NULL() instead, or should we reset pair->dma_chan[!dir] to NULL here on failure?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH v1 5/7] ASoC: fsl_asrc: Replace dma_request_slave_channel() by dma_request_chan()
Quoted 2 lines · On Tue, Sep 15, 2026 at 10:25:12AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] sound:fsl_asrc:dma_release_channel()dereferencesERR_PTRinfsl_asrc_dma_hw_free
Same answer as per patch 2.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 5/7] ASoC: fsl_asrc: Replace dma_request_slave_channel() by dma_request_chan()
In reply to Andy ShevchenkoQuoted 29 lines · Andy Shevchenko
Replace
dma_request_slave_channel()bydma_request_chan()as suggested since the former is deprecated.Signed-off-by Andy Shevchenko <[email protected]>--- sound/soc/fsl/fsl_asrc.c | 2 +- sound/soc/fsl/fsl_asrc_dma.c | 13 +++++++------ sound/soc/fsl/fsl_asrc_m2m.c | 8 ++++---- sound/soc/fsl/fsl_easrc.c | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-)sound/soc/fsl/fsl_asrc.c +1
-1@@ -638,7 +638,7 @@ static struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair,sprintf (name,"%cx%c" , dir ==IN ?'r' :'t' , index +'a' ); -return dma_request_slave_channel (&asrc->pdev->dev, name); +return dma_request_chan (&asrc->pdev->dev, name); } static int fsl_asrc_dai_startup(struct snd_pcm_substream *substream,sound/soc/fsl/fsl_asrc_dma.c +0
-0
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 197
Quoted 9 lines
sound/soc/fsl/fsl_asrc_dma.c +3
-2@@ -191,9 +191,10 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, dma_params_fe->maxburst = dma_params_be->maxburst; pair->dma_chan[!dir] = asrc->get_dma_channel (pair, !dir); -if (!pair->dma_chan[!dir]) { + ret =PTR_ERR_OR_ZERO (pair->dma_chan[!dir]); +if (ret) {dev_err (dev,"failed to request DMA channel\n" ); -return -EINVAL ; +return ret;
It progagate error to caller, it should be okay. I think it'd better mention at commit message
Frank
Quoted 68 lines
sound/soc/fsl/fsl_asrc_dma.c +4
-4} ret =snd_dmaengine_pcm_prepare_slave_config (substream, params, &config_fe);@@ -404,9 +405,9 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component,/* Request a dummy dma channel, which will be released later. */ tmp_chan = asrc->get_dma_channel (pair, dir); -if (!tmp_chan) { + ret =PTR_ERR_OR_ZERO (tmp_chan); +if (ret) {dev_err (dev,"failed to get dma channel\n" ); - ret = -EINVAL ; goto dma_chan_err; }@@ -497,9 +498,9 @@ static int fsl_asrc_dma_pcm_new(struct snd_soc_component *component,/* Request a dma channel, which will be released later. */ chan = asrc->get_dma_channel (pair,IN ); -if (!chan) { + ret =PTR_ERR_OR_ZERO (chan); +if (ret) {dev_err (dev,"failed to get dma channel\n" ); - ret = -EINVAL ; goto dma_chan_err; }sound/soc/fsl/fsl_asrc_m2m.c +4
-4@@ -503,16 +503,16 @@ static int fsl_asrc_m2m_comp_task_create(struct snd_compr_stream *stream,/* Request dma channels */ pair->dma_chan[IN ] = asrc->get_dma_channel (pair,IN ); -if (!pair->dma_chan[IN ]) { + ret =PTR_ERR_OR_ZERO (pair->dma_chan[IN ]); +if (ret) {dev_err (dev,"[ctx%d] failed to get input DMA channel\n" , pair->index); - ret = -EBUSY ; goto err_dma_channel_in; } pair->dma_chan[OUT ] = asrc->get_dma_channel (pair,OUT ); -if (!pair->dma_chan[OUT ]) { + ret =PTR_ERR_OR_ZERO (pair->dma_chan[OUT ]); +if (ret) {dev_err (dev,"[ctx%d] failed to get output DMA channel\n" , pair->index); - ret = -EBUSY ; goto err_dma_channel_out; }sound/soc/fsl/fsl_easrc.c +1
-2@@ -1433,7 +1433,7 @@ static struct dma_chan *fsl_easrc_get_dma_channel(struct fsl_asrc_pair *ctx,/* Example of dma name: ctx0_rx */ sprintf (name,"ctx%c_%cx" , index +'0' , dir ==IN ?'r' :'t' ); -return dma_request_slave_channel (&easrc->pdev->dev, name); +return dma_request_chan (&easrc->pdev->dev, name); };static const unsigned int easrc_rates[] = { --2.50.1
Re: [PATCH v1 5/7] ASoC: fsl_asrc: Replace dma_request_slave_channel() by dma_request_chan()
In reply to Andy ShevchenkoQuoted 5 lines · Andy Shevchenko
Replace
dma_request_slave_channel()bydma_request_chan()as suggested since the former is deprecated.Signed-off-by Andy Shevchenko <[email protected]>
Best regards
Shengjiu Wang
Quoted 102 lines
--- sound/soc/fsl/fsl_asrc.c | 2 +- sound/soc/fsl/fsl_asrc_dma.c | 13 +++++++------ sound/soc/fsl/fsl_asrc_m2m.c | 8 ++++---- sound/soc/fsl/fsl_easrc.c | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-)sound/soc/fsl/fsl_asrc.c +1
-1@@ -638,7 +638,7 @@ static struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair,sprintf (name,"%cx%c" , dir ==IN ?'r' :'t' , index +'a' ); -return dma_request_slave_channel (&asrc->pdev->dev, name); +return dma_request_chan (&asrc->pdev->dev, name); } static int fsl_asrc_dai_startup(struct snd_pcm_substream *substream,sound/soc/fsl/fsl_asrc_dma.c +7
-6@@ -191,9 +191,10 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, dma_params_fe->maxburst = dma_params_be->maxburst; pair->dma_chan[!dir] = asrc->get_dma_channel (pair, !dir); -if (!pair->dma_chan[!dir]) { + ret =PTR_ERR_OR_ZERO (pair->dma_chan[!dir]); +if (ret) {dev_err (dev,"failed to request DMA channel\n" ); -return -EINVAL ; +return ret; } ret =snd_dmaengine_pcm_prepare_slave_config (substream, params, &config_fe);@@ -404,9 +405,9 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component,/* Request a dummy dma channel, which will be released later. */ tmp_chan = asrc->get_dma_channel (pair, dir); -if (!tmp_chan) { + ret =PTR_ERR_OR_ZERO (tmp_chan); +if (ret) {dev_err (dev,"failed to get dma channel\n" ); - ret = -EINVAL ; goto dma_chan_err; }@@ -497,9 +498,9 @@ static int fsl_asrc_dma_pcm_new(struct snd_soc_component *component,/* Request a dma channel, which will be released later. */ chan = asrc->get_dma_channel (pair,IN ); -if (!chan) { + ret =PTR_ERR_OR_ZERO (chan); +if (ret) {dev_err (dev,"failed to get dma channel\n" ); - ret = -EINVAL ; goto dma_chan_err; }sound/soc/fsl/fsl_asrc_m2m.c +4
-4@@ -503,16 +503,16 @@ static int fsl_asrc_m2m_comp_task_create(struct snd_compr_stream *stream,/* Request dma channels */ pair->dma_chan[IN ] = asrc->get_dma_channel (pair,IN ); -if (!pair->dma_chan[IN ]) { + ret =PTR_ERR_OR_ZERO (pair->dma_chan[IN ]); +if (ret) {dev_err (dev,"[ctx%d] failed to get input DMA channel\n" , pair->index); - ret = -EBUSY ; goto err_dma_channel_in; } pair->dma_chan[OUT ] = asrc->get_dma_channel (pair,OUT ); -if (!pair->dma_chan[OUT ]) { + ret =PTR_ERR_OR_ZERO (pair->dma_chan[OUT ]); +if (ret) {dev_err (dev,"[ctx%d] failed to get output DMA channel\n" , pair->index); - ret = -EBUSY ; goto err_dma_channel_out; }sound/soc/fsl/fsl_easrc.c +1
-2@@ -1433,7 +1433,7 @@ static struct dma_chan *fsl_easrc_get_dma_channel(struct fsl_asrc_pair *ctx,/* Example of dma name: ctx0_rx */ sprintf (name,"ctx%c_%cx" , index +'0' , dir ==IN ?'r' :'t' ); -return dma_request_slave_channel (&easrc->pdev->dev, name); +return dma_request_chan (&easrc->pdev->dev, name); };static const unsigned int easrc_rates[] = { --2.50.1
PATCH 6/7 gpib: fmh_gpib: Replace dma_request_slave_channel() by dma_request_chan()
In reply to Andy ShevchenkoReplace dma_request_slave_channel() by dma_request_chan() as suggested since the former is deprecated.
--- drivers/gpib/fmh_gpib/fmh_gpib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpib/fmh_gpib/fmh_gpib.c +4 -3
@@ -1458,10 +1458,11 @@ static int fmh_gpib_attach_impl(struct gpib_board *board, const struct gpib_boar e_priv->irq = irq;if (acquire_dma) { - e_priv->dma_channel =dma_request_slave_channel (board->dev,"rxtx" ); -if (!e_priv->dma_channel) { + e_priv->dma_channel =dma_request_chan (board->dev,"rxtx" ); + retval =PTR_ERR_OR_ZERO (e_priv->dma_channel); +if (retval) {dev_err (board->dev,"failed to acquire dma channel \"rxtx\".\n" ); -return -EIO ; +return retval; } }/*
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH v1 6/7] gpib: fmh_gpib: Replace dma_request_slave_channel() by dma_request_chan()
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] gpib: fmh_gpib: unhandled ERR_PTR from dma_request_chan() causes crash in fmh_gpib_detach() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] gpib: fmh_gpib: unhandled ERR_PTR from dma_request_chan() causes crash in fmh_gpib_detach() --
commit 7e5dd98fffd0fbb658150cf070a074a056171a33
Author: Andy Shevchenko <[email protected]>
gpib: fmh_gpib: Replace dma_request_slave_channel() by dma_request_chan()
This commit replaces the deprecated dma_request_slave_channel() with dma_request_chan(). It updates the error checking to use PTR_ERR_OR_ZERO() appropriately for the new function.
Quoted 6 lines
drivers/gpib/fmh_gpib/fmh_gpib.c +0
-0@@ -1458,10 +1458,11 @@ static int fmh_gpib_attach_impl(struct gpib_board *board, const struct gpib_boar e_priv->irq = irq;
drivers/gpib/fmh_gpib/fmh_gpib.c static int fmh_gpib_attach_impl(struct gpib_board *board, const struct gpib_boar · line 1465
Quoted 10 lines
drivers/gpib/fmh_gpib/fmh_gpib.c +4
-3if (acquire_dma) { - e_priv->dma_channel =dma_request_slave_channel (board->dev,"rxtx" ); -if (!e_priv->dma_channel) { + e_priv->dma_channel =dma_request_chan (board->dev,"rxtx" ); + retval =PTR_ERR_OR_ZERO (e_priv->dma_channel); +if (retval) {dev_err (board->dev,"failed to acquire dma channel \"rxtx\".\n" ); -return -EIO ; +return retval;
[Severity: High]
Does this code leave an ERR_PTR in e_priv->dma_channel on failure?
If dma_request_chan() fails, it returns an error pointer which is stored in e_priv->dma_channel. When fmh_gpib_attach_impl() returns this error code, the GPIB core intercepts the attach failure and calls fmh_gpib_detach() to clean up.
Since fmh_gpib_detach() handles cleanup by checking for NULL:
drivers/gpib/fmh_gpib/fmh_gpib.c:fmh_gpib_detach() {
...
if (e_priv) {
if (e_priv->dma_channel)
dma_release_channel(e_priv->dma_channel);
...
}It will evaluate the ERR_PTR as true and attempt to dereference it inside dma_release_channel(), leading to a kernel oops or panic. Should e_priv->dma_channel be reset to NULL before returning the error?
Quoted 3 lines
drivers/gpib/fmh_gpib/fmh_gpib.c +0
-0} }/*
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Re: [PATCH v1 6/7] gpib: fmh_gpib: Replace dma_request_slave_channel() by dma_request_chan()
Quoted 2 lines · On Tue, Sep 15, 2026 at 10:21:44AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] gpib:fmh_gpib: unhandledERR_PTRfromdma_request_chan()causes crash infmh_gpib_detach()
Same as per patch 2.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 6/7] gpib: fmh_gpib: Replace dma_request_slave_channel() by dma_request_chan()
In reply to Andy ShevchenkoQuoted 16 lines · Andy Shevchenko
Replace
dma_request_slave_channel()bydma_request_chan()as suggested since the former is deprecated.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpib/fmh_gpib/fmh_gpib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpib/fmh_gpib/fmh_gpib.c +0
-0@@ -1458,10 +1458,11 @@ static int fmh_gpib_attach_impl(struct gpib_board *board, const struct gpib_boar e_priv->irq = irq;if (acquire_dma) {
drivers/gpib/fmh_gpib/fmh_gpib.c static int fmh_gpib_attach_impl(struct gpib_board *board, const struct gpib_boar · line 1467
Quoted 10 lines
drivers/gpib/fmh_gpib/fmh_gpib.c +4
-3- e_priv->dma_channel =dma_request_slave_channel (board->dev,"rxtx" ); -if (!e_priv->dma_channel) { + e_priv->dma_channel =dma_request_chan (board->dev,"rxtx" ); + retval =PTR_ERR_OR_ZERO (e_priv->dma_channel); +if (retval) {dev_err (board->dev,"failed to acquire dma channel \"rxtx\".\n" ); -return -EIO ; +return retval; } }
PATCH 7/7 dmaengine: Remove deprecated dma_request_slave_channel()
In reply to Andy ShevchenkoNo more users.
--- include/linux/dmaengine.h | 9 --------- 1 file changed, 9 deletions(-)
include/linux/dmaengine.h +0 -9
@@ -1763,15 +1763,6 @@ void dma_run_dependencies(struct dma_async_tx_descriptor *tx);#define dma_request_channel (mask, x, y) \ __dma_request_channel(&(mask), x, y, NULL) -/* Deprecated, please use dma_request_chan() directly */ -static inline struct dma_chan *__deprecated -dma_request_slave_channel (struct device *dev,const char *name) -{ -struct dma_chan *ch =dma_request_chan (dev, name); - -return IS_ERR (ch) ?NULL : ch; -} -static inline struct dma_chan *dma_request_slave_channel_compat(const dma_cap_mask_t mask, dma_filter_fn fn, void *fn_param,
Signature · 1 line
2.50.1
Re: [PATCH v1 7/7] dmaengine: Remove deprecated dma_request_slave_channel()
Quoted 4 lines · Andy Shevchenko
No more users.
Signed-off-by Andy Shevchenko <[email protected]>---
Quoted 26 lines
include/linux/dmaengine.h | 9 --------- 1 file changed, 9 deletions(-)include/linux/dmaengine.h +0
-10@@ -1763,15 +1763,6 @@ void dma_run_dependencies(struct dma_async_tx_descriptor *tx);#define dma_request_channel (mask, x, y) \ __dma_request_channel(&(mask), x, y, NULL) -/* Deprecated, please use dma_request_chan() directly */ -static inline struct dma_chan *__deprecated -dma_request_slave_channel (struct device *dev,const char *name) -{ -struct dma_chan *ch =dma_request_chan (dev, name); - -return IS_ERR (ch) ?NULL : ch; -} -static inline struct dma_chan *dma_request_slave_channel_compat(const dma_cap_mask_t mask, dma_filter_fn fn, void *fn_param, --2.50.1
Re: [PATCH v1 7/7] dmaengine: Remove deprecated dma_request_slave_channel()
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
No more users.
Signed-off-by Andy Shevchenko <[email protected]>
Signature · 1 line
~Vinod