Skip to contentSkip to conversation

ALSA - hda: hdmi check NULL pointer in hdmi_set_chmap

PATCH In review [email protected] 3 participants 3 messages Mar 30, 2016 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA - hda: hdmi check NULL pointer in hdmi_set_chmap

From: Libin Yang <[email protected]>

Make sure per_pin is not NULL before using it.

---
 sound/pci/hda/patch_hdmi.c | 2 ++
 1 file changed, 2 insertions(+)
sound/pci/hda/patch_hdmi.c +2 -0
index 4833c7b..c99289d 100644
@@ -1858,6 +1858,8 @@ static void hdmi_set_chmap(struct hdac_device *hdac, int pcm_idx,
 	struct hdmi_spec *spec = codec->spec;
 	struct hdmi_spec_per_pin *per_pin = pcm_idx_to_pin(spec, pcm_idx);
 
+	if (!per_pin)
+		return;
 	mutex_lock(&per_pin->lock);
 	per_pin->chmap_set = true;
 	memcpy(per_pin->chmap, chmap, ARRAY_SIZE(per_pin->chmap));
Signature · 1 line
1.9.1
#1 lore raw
Quoted 3 lines · On Wed, Mar 30, 2016 at 08:38:42AM +0530, [email protected] wrote:

From: Libin Yang <[email protected]>

Make sure per_pin is not NULL before using it.

Hi Libin,

In the beginning of ctl_put handler this NULL check is already done. Are you supposed to call this set_chmap from other places too?

Regards,
Subhransu

Quoted 26 lines
---
 sound/pci/hda/patch_hdmi.c | 2 ++
 1 file changed, 2 insertions(+)
sound/pci/hda/patch_hdmi.c +2 -0
index 4833c7b..c99289d 100644
@@ -1858,6 +1858,8 @@ static void hdmi_set_chmap(struct hdac_device *hdac, int pcm_idx,
 	struct hdmi_spec *spec = codec->spec;
 	struct hdmi_spec_per_pin *per_pin = pcm_idx_to_pin(spec, pcm_idx);
 
+	if (!per_pin)
+		return;
 	mutex_lock(&per_pin->lock);
 	per_pin->chmap_set = true;
 	memcpy(per_pin->chmap, chmap, ARRAY_SIZE(per_pin->chmap));
Signature · 6 lines
1.9.1

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#2 lore raw

Hi Subhransu,

Quoted 11 lines

-----Original Message-----
From: Prusty, Subhransu S
Sent: Wednesday, March 30, 2016 12:40 PM
To: [email protected]
Cc: [email protected]; [email protected]; Yang, Libin; Lin, Mengdong
Subject: Re: [alsa-devel] [PATCH] ALSA - hda: hdmi check NULL pointer in hdmi_set_chmap

On Wed, Mar 30, 2016 at 08:38:42AM +0530, [email protected] wrote:

Quoted 8 lines
Quoted 3 lines

From: Libin Yang <[email protected]>

Make sure per_pin is not NULL before using it.

Hi Libin,

In the beginning of ctl_put handler this NULL check is already done. Are you supposed to call this set_chmap from other places too?

I made the patch because it is required by the klocwork. It's not a real bug so far, I think.

Regards,
Libin

Quoted 35 lines

Regards,
Subhransu

Review

Quoted 7 lines
---
 sound/pci/hda/patch_hdmi.c | 2 ++
 1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/sound/pci/hda/patch_hdmi.c

sound/pci/hda/patch_hdmi.c static void hdmi_set_chmap(struct

Quoted 4 lines

index 4833c7b..c99289d 100644

sound/pci/hda/patch_hdmi.c +0 -0
@@ -1858,6 +1858,8 @@ static void hdmi_set_chmap(struct

hdac_device *hdac, int pcm_idx,

sound/pci/hda/patch_hdmi.c static void hdmi_set_chmap(struct · line 1859

Quoted 2 lines
sound/pci/hda/patch_hdmi.c +0 -0
 	struct hdmi_spec *spec = codec->spec;
 	struct hdmi_spec_per_pin *per_pin = pcm_idx_to_pin(spec,

pcm_idx);

Quoted 10 lines
sound/pci/hda/patch_hdmi.c +2 -1
+	if (!per_pin)
+		return;
 	mutex_lock(&per_pin->lock);
 	per_pin->chmap_set = true;
 	memcpy(per_pin->chmap, chmap, ARRAY_SIZE(per_pin-
 chmap));
--

1.9.1

Quoted 4 lines

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

--