[alsa-devel] [PATCH 0/5] 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(-)
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/x86/intel_hdmi_audio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c index 16ca91f57e7f..80f79ecffc71 100644 --- a/sound/x86/intel_hdmi_audio.c +++ b/sound/x86/intel_hdmi_audio.c @@ -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 */
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/arm/aaci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 0c3f073e2600..a2d4b41096e0 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -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;
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/soc/amd/raven/acp3x-pcm-dma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index 3d58338fa3cf..3e7d4099364c 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -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); }
On Mon, Feb 04, 2019 at 02:42:20PM +0100, Takashi Iwai wrote:
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.
Acked-by: Mark Brown broonie@kernel.org
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/soc/sh/siu_pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c index e263757e4a69..23384c477740 100644 --- a/sound/soc/sh/siu_pcm.c +++ b/sound/soc/sh/siu_pcm.c @@ -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,
On Mon, Feb 04, 2019 at 02:42:21PM +0100, Takashi Iwai wrote:
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.
Acked-by: Mark Brown broonie@kernel.org
Since we covered all callers with NULL device pointer, let's catch the remaining calls with NULL and warn explicitly.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/core/memalloc.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 59a4adc286ed..eb974235c92b 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -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;
On Mon, Feb 04, 2019 at 02:42:17PM +0100, Takashi Iwai wrote:
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 a lot for doing this work!
Acked-by: Christoph Hellwig hch@lst.de
participants (3)
-
Christoph Hellwig
-
Mark Brown
-
Takashi Iwai