alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations
@ 2019-02-04 13:42 Takashi Iwai
  2019-02-04 13:42 ` [PATCH 1/5] ALSA: x86: Avoid passing NULL to memory allocators Takashi Iwai
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Takashi Iwai @ 2019-02-04 13:42 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Christoph Hellwig

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(-)

-- 
2.16.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/5] ALSA: x86: Avoid passing NULL to memory allocators
  2019-02-04 13:42 [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations Takashi Iwai
@ 2019-02-04 13:42 ` Takashi Iwai
  2019-02-04 13:42 ` [PATCH 2/5] ALSA: arm: " Takashi Iwai
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2019-02-04 13:42 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Christoph Hellwig

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 */
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/5] ALSA: arm: Avoid passing NULL to memory allocators
  2019-02-04 13:42 [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations Takashi Iwai
  2019-02-04 13:42 ` [PATCH 1/5] ALSA: x86: Avoid passing NULL to memory allocators Takashi Iwai
@ 2019-02-04 13:42 ` Takashi Iwai
  2019-02-04 13:42 ` [PATCH 3/5] ASoC: amd: " Takashi Iwai
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2019-02-04 13:42 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Christoph Hellwig

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;
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/5] ASoC: amd: Avoid passing NULL to memory allocators
  2019-02-04 13:42 [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations Takashi Iwai
  2019-02-04 13:42 ` [PATCH 1/5] ALSA: x86: Avoid passing NULL to memory allocators Takashi Iwai
  2019-02-04 13:42 ` [PATCH 2/5] ALSA: arm: " Takashi Iwai
@ 2019-02-04 13:42 ` Takashi Iwai
  2019-02-04 21:00   ` Mark Brown
  2019-02-04 13:42 ` [PATCH 4/5] ASoC: sh: " Takashi Iwai
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Takashi Iwai @ 2019-02-04 13:42 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Christoph Hellwig

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);
 }
 
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/5] ASoC: sh: Avoid passing NULL to memory allocators
  2019-02-04 13:42 [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations Takashi Iwai
                   ` (2 preceding siblings ...)
  2019-02-04 13:42 ` [PATCH 3/5] ASoC: amd: " Takashi Iwai
@ 2019-02-04 13:42 ` Takashi Iwai
  2019-02-04 21:00   ` Mark Brown
  2019-02-04 13:42 ` [PATCH 5/5] ALSA: core: Don't allow NULL device for memory allocation Takashi Iwai
  2019-02-04 15:50 ` [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations Christoph Hellwig
  5 siblings, 1 reply; 9+ messages in thread
From: Takashi Iwai @ 2019-02-04 13:42 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Christoph Hellwig

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,
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 5/5] ALSA: core: Don't allow NULL device for memory allocation
  2019-02-04 13:42 [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations Takashi Iwai
                   ` (3 preceding siblings ...)
  2019-02-04 13:42 ` [PATCH 4/5] ASoC: sh: " Takashi Iwai
@ 2019-02-04 13:42 ` Takashi Iwai
  2019-02-04 15:50 ` [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations Christoph Hellwig
  5 siblings, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2019-02-04 13:42 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Christoph Hellwig

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;
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations
  2019-02-04 13:42 [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations Takashi Iwai
                   ` (4 preceding siblings ...)
  2019-02-04 13:42 ` [PATCH 5/5] ALSA: core: Don't allow NULL device for memory allocation Takashi Iwai
@ 2019-02-04 15:50 ` Christoph Hellwig
  5 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2019-02-04 15:50 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, Mark Brown, Christoph Hellwig

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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/5] ASoC: amd: Avoid passing NULL to memory allocators
  2019-02-04 13:42 ` [PATCH 3/5] ASoC: amd: " Takashi Iwai
@ 2019-02-04 21:00   ` Mark Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2019-02-04 21:00 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, Christoph Hellwig


[-- Attachment #1.1: Type: text/plain, Size: 310 bytes --]

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>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/5] ASoC: sh: Avoid passing NULL to memory allocators
  2019-02-04 13:42 ` [PATCH 4/5] ASoC: sh: " Takashi Iwai
@ 2019-02-04 21:00   ` Mark Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2019-02-04 21:00 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, Christoph Hellwig


[-- Attachment #1.1: Type: text/plain, Size: 310 bytes --]

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>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-02-04 21:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-04 13:42 [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations Takashi Iwai
2019-02-04 13:42 ` [PATCH 1/5] ALSA: x86: Avoid passing NULL to memory allocators Takashi Iwai
2019-02-04 13:42 ` [PATCH 2/5] ALSA: arm: " Takashi Iwai
2019-02-04 13:42 ` [PATCH 3/5] ASoC: amd: " Takashi Iwai
2019-02-04 21:00   ` Mark Brown
2019-02-04 13:42 ` [PATCH 4/5] ASoC: sh: " Takashi Iwai
2019-02-04 21:00   ` Mark Brown
2019-02-04 13:42 ` [PATCH 5/5] ALSA: core: Don't allow NULL device for memory allocation Takashi Iwai
2019-02-04 15:50 ` [PATCH 0/5] ALSA: Fix remaining NULL device with memory allocations Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).