2012-08-31 03:25:34

by Prasad Joshi

[permalink] [raw]
Subject: [PATCH] ASoC: correct the check for NULL dma_buffer pointer

The if condition
if (!buf && !buf->area)

checks if the buf pointer is NULL and then dereferences it again to
check if the buffer area is NULL, resulting in possible NULL
dereference.

Signed-off-by: Prasad Joshi <[email protected]>
---
sound/soc/spear/spear_pcm.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sound/soc/spear/spear_pcm.c b/sound/soc/spear/spear_pcm.c
index 97c2cac..8c7f237 100644
--- a/sound/soc/spear/spear_pcm.c
+++ b/sound/soc/spear/spear_pcm.c
@@ -138,7 +138,7 @@ static void spear_pcm_free(struct snd_pcm *pcm)
continue;

buf = &substream->dma_buffer;
- if (!buf && !buf->area)
+ if (!buf || !buf->area)
continue;

dma_free_writecombine(pcm->card->dev, buf->bytes,
--
1.7.5.4


2012-08-31 21:24:42

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] ASoC: correct the check for NULL dma_buffer pointer

On Fri, Aug 31, 2012 at 08:55:21AM +0530, Prasad Joshi wrote:
> The if condition
> if (!buf && !buf->area)
>
> checks if the buf pointer is NULL and then dereferences it again to
> check if the buffer area is NULL, resulting in possible NULL
> dereference.

Applied, thanks.