diff mbox

[RESEND,V2] ALSA: hda: fix possible NULL dereference

Message ID 20150824121139.GB13757@mo-online.de (mailing list archive)
State New, archived
Headers show

Commit Message

Markus Osterhoff Aug. 24, 2015, 12:11 p.m. UTC
After a for-loop was replaced by list_for_each_entry, see
Commit bbbc7e8502c9 ("ALSA: hda - Allocate hda_pcm objects dynamically"),
Commit 751e2216899c ("ALSA: hda: fix possible null dereference"),
a possible NULL pointer dereference has been introduced; this patch adds
the NULL check on pcm->pcm, while leaving a potentially superfluous
check on pcm itself untouched.

Signed-off-by: Markus Osterhoff <linux-kernel@k-raum.org>
---
 sound/pci/hda/hda_codec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Takashi Iwai Aug. 24, 2015, 1:04 p.m. UTC | #1
On Mon, 24 Aug 2015 14:11:39 +0200,
Markus Osterhoff wrote:
> 
> After a for-loop was replaced by list_for_each_entry, see
> Commit bbbc7e8502c9 ("ALSA: hda - Allocate hda_pcm objects dynamically"),
> Commit 751e2216899c ("ALSA: hda: fix possible null dereference"),
> a possible NULL pointer dereference has been introduced; this patch adds
> the NULL check on pcm->pcm, while leaving a potentially superfluous
> check on pcm itself untouched.
> 
> Signed-off-by: Markus Osterhoff <linux-kernel@k-raum.org>

The patch couldn't be applied cleanly because the tabs are replaced
wrongly with spaces, so I applied it manually now.  Please fix your
MUA or the way to create a patch at the next time.


thanks,


Takashi

> ---
>  sound/pci/hda/hda_codec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
> index 5de3c5d..d1a2cb6 100644
> --- a/sound/pci/hda/hda_codec.c
> +++ b/sound/pci/hda/hda_codec.c
> @@ -3172,7 +3172,7 @@ static int add_std_chmaps(struct hda_codec *codec)
>                         struct snd_pcm_chmap *chmap;
>                         const struct snd_pcm_chmap_elem *elem;
>  
> -                       if (!pcm || pcm->own_chmap ||
> +                       if (!pcm || !pcm->pcm || pcm->own_chmap ||
>                             !hinfo->substreams)
>                                 continue;
>                         elem = hinfo->chmap ? hinfo->chmap : snd_pcm_std_chmaps;
>
diff mbox

Patch

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 5de3c5d..d1a2cb6 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -3172,7 +3172,7 @@  static int add_std_chmaps(struct hda_codec *codec)
                        struct snd_pcm_chmap *chmap;
                        const struct snd_pcm_chmap_elem *elem;
 
-                       if (!pcm || pcm->own_chmap ||
+                       if (!pcm || !pcm->pcm || pcm->own_chmap ||
                            !hinfo->substreams)
                                continue;
                        elem = hinfo->chmap ? hinfo->chmap : snd_pcm_std_chmaps;