* [PATCH] ALSA: pcm: Check for null pointer of pointer substream before dereferencing it
@ 2022-04-24 20:59 Colin Ian King
2022-04-25 5:53 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Colin Ian King @ 2022-04-24 20:59 UTC (permalink / raw)
To: Takashi Iwai, alsa-devel; +Cc: kernel-janitors, linux-kernel
Pointer substream is being dereferenced on the assignment of pointer card
before substream is being null checked with the macro PCM_RUNTIME_CHECK.
Although PCM_RUNTIME_CHECK calls BUG_ON, it still is useful to perform the
the pointer check before card is assigned.
Fixes: commit d4cfb30fce03 ("ALSA: pcm: Set per-card upper limit of PCM buffer allocations")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
sound/core/pcm_memory.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c
index 8848d2f3160d..b8296b6eb2c1 100644
--- a/sound/core/pcm_memory.c
+++ b/sound/core/pcm_memory.c
@@ -453,7 +453,6 @@ EXPORT_SYMBOL(snd_pcm_lib_malloc_pages);
*/
int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream)
{
- struct snd_card *card = substream->pcm->card;
struct snd_pcm_runtime *runtime;
if (PCM_RUNTIME_CHECK(substream))
@@ -462,6 +461,8 @@ int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream)
if (runtime->dma_area == NULL)
return 0;
if (runtime->dma_buffer_p != &substream->dma_buffer) {
+ struct snd_card *card = substream->pcm->card;
+
/* it's a newly allocated buffer. release it now. */
do_free_pages(card, runtime->dma_buffer_p);
kfree(runtime->dma_buffer_p);
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: pcm: Check for null pointer of pointer substream before dereferencing it
2022-04-24 20:59 [PATCH] ALSA: pcm: Check for null pointer of pointer substream before dereferencing it Colin Ian King
@ 2022-04-25 5:53 ` Takashi Iwai
0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2022-04-25 5:53 UTC (permalink / raw)
To: Colin Ian King; +Cc: Takashi Iwai, alsa-devel, kernel-janitors, linux-kernel
On Sun, 24 Apr 2022 22:59:45 +0200,
Colin Ian King wrote:
>
> Pointer substream is being dereferenced on the assignment of pointer card
> before substream is being null checked with the macro PCM_RUNTIME_CHECK.
> Although PCM_RUNTIME_CHECK calls BUG_ON, it still is useful to perform the
> the pointer check before card is assigned.
>
> Fixes: commit d4cfb30fce03 ("ALSA: pcm: Set per-card upper limit of PCM buffer allocations")
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Thanks, applied with the correction of Fixes tag.
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: pcm: Check for null pointer of pointer substream before dereferencing it
@ 2022-04-25 5:53 ` Takashi Iwai
0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2022-04-25 5:53 UTC (permalink / raw)
To: Colin Ian King; +Cc: alsa-devel, kernel-janitors, Takashi Iwai, linux-kernel
On Sun, 24 Apr 2022 22:59:45 +0200,
Colin Ian King wrote:
>
> Pointer substream is being dereferenced on the assignment of pointer card
> before substream is being null checked with the macro PCM_RUNTIME_CHECK.
> Although PCM_RUNTIME_CHECK calls BUG_ON, it still is useful to perform the
> the pointer check before card is assigned.
>
> Fixes: commit d4cfb30fce03 ("ALSA: pcm: Set per-card upper limit of PCM buffer allocations")
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Thanks, applied with the correction of Fixes tag.
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-25 5:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24 20:59 [PATCH] ALSA: pcm: Check for null pointer of pointer substream before dereferencing it Colin Ian King
2022-04-25 5:53 ` Takashi Iwai
2022-04-25 5:53 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.