ALSA: Fix remaining NULL device with memory allocations
Subsystems (4)
cover ALSA: Fix remaining NULL device with memory allocations
Hi,
this patchset covers the still remaining drivers calling the memory allocation with NULL device pointer. Simply card->dev is passed there.
Mark, two of them are trivial fixes for ASoC, and I'd like to merge them through my tree, since the last patch adds an explicit WARN_ON(). Give me Ack's if they are OK.
thanks,
Takashi
===
Takashi Iwai (5):
ALSA: x86: Avoid passing NULL to memory allocators
ALSA: arm: Avoid passing NULL to memory allocators
ASoC: amd: Avoid passing NULL to memory allocators
ASoC: sh: Avoid passing NULL to memory allocators
ALSA: core: Don't allow NULL device for memory allocation
sound/arm/aaci.c | 3 ++- sound/core/memalloc.c | 2 ++ sound/soc/amd/raven/acp3x-pcm-dma.c | 3 ++- sound/soc/sh/siu_pcm.c | 2 +- sound/x86/intel_hdmi_audio.c | 3 ++- 5 files changed, 9 insertions(+), 4 deletions(-)
Signature · 1 line
2.16.4
PATCH 1/5 ALSA: x86: Avoid passing NULL to memory allocators
We should pass a proper non-NULL device object to memory allocators
although it was accepted in the past. The card->dev points to the most appropriate device object in such a case, so let's put it.
--- sound/x86/intel_hdmi_audio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/x86/intel_hdmi_audio.c +2 -1
@@ -1812,7 +1812,8 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)* try to allocate 600k buffer as default which is large enough */ snd_pcm_lib_preallocate_pages_for_all (pcm, -SNDRV_DMA_TYPE_DEV_UC ,NULL , +SNDRV_DMA_TYPE_DEV_UC , + card->dev,HAD_DEFAULT_BUFFER ,HAD_MAX_BUFFER );/* create controls */
Signature · 1 line
2.16.4
PATCH 2/5 ALSA: arm: Avoid passing NULL to memory allocators
In reply to Takashi IwaiWe should pass a proper non-NULL device object to memory allocators
although it was accepted in the past. The card->dev points to the most appropriate device object in such a case, so let's put it.
--- sound/arm/aaci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/arm/aaci.c +2 -1
@@ -941,7 +941,8 @@ static int aaci_init_pcm(struct aaci *aaci)snd_pcm_set_ops (pcm,SNDRV_PCM_STREAM_PLAYBACK , &aaci_playback_ops);snd_pcm_set_ops (pcm,SNDRV_PCM_STREAM_CAPTURE , &aaci_capture_ops);snd_pcm_lib_preallocate_pages_for_all (pcm,SNDRV_DMA_TYPE_DEV , -NULL ,0 ,64 *1024 ); + aaci->card->dev, +0 ,64 *1024 ); }return ret;
Signature · 1 line
2.16.4
PATCH 3/5 ASoC: amd: Avoid passing NULL to memory allocators
In reply to Takashi IwaiWe should pass a proper non-NULL device object to memory allocators although it was accepted in the past. The card->dev points to the most appropriate device object in such a case, so let's put it.
--- sound/soc/amd/raven/acp3x-pcm-dma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/amd/raven/acp3x-pcm-dma.c +2 -1
@@ -369,7 +369,8 @@ static int acp3x_dma_new(struct snd_soc_pcm_runtime *rtd) {return snd_pcm_lib_preallocate_pages_for_all (rtd->pcm,SNDRV_DMA_TYPE_DEV , -NULL ,MIN_BUFFER , + rtd->pcm->card->dev, +MIN_BUFFER ,MAX_BUFFER ); }
Signature · 1 line
2.16.4
Re: [PATCH 3/5] ASoC: amd: Avoid passing NULL to memory allocators
Quoted 3 lines · Takashi Iwai
We should pass a proper non-NULL device object to memory allocators although it was accepted in the past. The
card->devpoints to the most appropriate device object in such a case, so let's put it.
PATCH 4/5 ASoC: sh: Avoid passing NULL to memory allocators
In reply to Takashi IwaiWe should pass a proper non-NULL device object to memory allocators
although it was accepted in the past. The card->dev points to the most appropriate device object in such a case, so let's put it.
--- sound/soc/sh/siu_pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sh/siu_pcm.c +1 -1
@@ -542,7 +542,7 @@ static int siu_pcm_new(struct snd_soc_pcm_runtime *rtd)return ret; ret =snd_pcm_lib_preallocate_pages_for_all (pcm, -SNDRV_DMA_TYPE_DEV ,NULL , +SNDRV_DMA_TYPE_DEV , card->dev,SIU_BUFFER_BYTES_MAX ,SIU_BUFFER_BYTES_MAX );if (ret <0 ) { dev_err(card->dev,
Signature · 1 line
2.16.4
Re: [PATCH 4/5] ASoC: sh: Avoid passing NULL to memory allocators
Quoted 3 lines · Takashi Iwai
We should pass a proper non-NULL device object to memory allocators
although it was accepted in the past. Thecard->devpoints to the most appropriate device object in such a case, so let's put it.
PATCH 5/5 ALSA: core: Don't allow NULL device for memory allocation
In reply to Takashi IwaiSince we covered all callers with NULL device pointer, let's catch the remaining calls with NULL and warn explicitly.
--- sound/core/memalloc.c | 2 ++ 1 file changed, 2 insertions(+)
sound/core/memalloc.c +2 -0
@@ -182,6 +182,8 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,return -ENXIO ;if (WARN_ON (!dmab))return -ENXIO ; +if (WARN_ON (!device)) +return -EINVAL ; dmab->dev.type = type; dmab->dev.dev = device;
Signature · 1 line
2.16.4
Quoted 10 lines · Takashi Iwai
Hi,
this patchset covers the still remaining drivers calling the memory allocation with NULL device pointer. Simply
card->devis passed there.Mark, two of them are trivial fixes for ASoC, and I'd like to merge them through my tree, since the last patch adds an explicit
WARN_ON(). Give me Ack's if they are OK.
Thanks a lot for doing this work!