diff mbox

ASoC: hdac_hdmi: Potential NULL deref in hdac_hdmi_get_spk_alloc()

Message ID 20160503074258.GA9722@mwanda (mailing list archive)
State Accepted
Commit 8f658815da156a9239b98b34e5ba1d3db71a2f6e
Headers show

Commit Message

Dan Carpenter May 3, 2016, 7:42 a.m. UTC
We intended || here instead of &&.  The original code potentially leads
to a NULL dereference.

Fixes: 2889099eb8cd ('ASoC: hdac_hdmi: Register chmap controls and ops')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Takashi Sakamoto May 3, 2016, 7:58 a.m. UTC | #1
On May 03 2016 16:42, Dan Carpenter wrote:
> We intended || here instead of &&.  The original code potentially leads
> to a NULL dereference.
> 
> Fixes: 2889099eb8cd ('ASoC: hdac_hdmi: Register chmap controls and ops')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Indeed.

Reviewd-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

> diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
> index 3043120..7e7ff1b 100644
> --- a/sound/soc/codecs/hdac_hdmi.c
> +++ b/sound/soc/codecs/hdac_hdmi.c
> @@ -1609,7 +1609,7 @@ static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdac, int pcm_idx)
>  	struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
>  	struct hdac_hdmi_pin *pin = pcm->pin;
>  
> -	if (!pin && !pin->eld.eld_valid)
> +	if (!pin || !pin->eld.eld_valid)
>  		return 0;
>  
>  	return pin->eld.info.spk_alloc;


Regards

Takashi Sakamoto
Vinod Koul May 3, 2016, 9:56 a.m. UTC | #2
On Tue, May 03, 2016 at 10:42:58AM +0300, Dan Carpenter wrote:
> We intended || here instead of &&.  The original code potentially leads
> to a NULL dereference.

This looks good to me, I will test this and get back

> 
> Fixes: 2889099eb8cd ('ASoC: hdac_hdmi: Register chmap controls and ops')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
> index 3043120..7e7ff1b 100644
> --- a/sound/soc/codecs/hdac_hdmi.c
> +++ b/sound/soc/codecs/hdac_hdmi.c
> @@ -1609,7 +1609,7 @@ static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdac, int pcm_idx)
>  	struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
>  	struct hdac_hdmi_pin *pin = pcm->pin;
>  
> -	if (!pin && !pin->eld.eld_valid)
> +	if (!pin || !pin->eld.eld_valid)
>  		return 0;
>  
>  	return pin->eld.info.spk_alloc;
Vinod Koul May 3, 2016, 4:06 p.m. UTC | #3
On Tue, May 03, 2016 at 03:26:39PM +0530, Vinod Koul wrote:
> On Tue, May 03, 2016 at 10:42:58AM +0300, Dan Carpenter wrote:
> > We intended || here instead of &&.  The original code potentially leads
> > to a NULL dereference.
> 
> This looks good to me, I will test this and get back

Acked-by: Vinod Koul <vinod.koul@intel.com>
Tested-by: Sachin Mokashi <sachinx.mokashi@intel.com>
diff mbox

Patch

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 3043120..7e7ff1b 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1609,7 +1609,7 @@  static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdac, int pcm_idx)
 	struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
 	struct hdac_hdmi_pin *pin = pcm->pin;
 
-	if (!pin && !pin->eld.eld_valid)
+	if (!pin || !pin->eld.eld_valid)
 		return 0;
 
 	return pin->eld.info.spk_alloc;