From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH 2/3] ALSA: hda - hdmi: Do not expose eld data when eld is invalid Date: Mon, 18 Feb 2013 15:39:23 +0100 Message-ID: References: <1361193073-7199-1-git-send-email-david.henningsson@canonical.com> <1361193073-7199-3-git-send-email-david.henningsson@canonical.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 1E64C261603 for ; Mon, 18 Feb 2013 15:39:25 +0100 (CET) In-Reply-To: <1361193073-7199-3-git-send-email-david.henningsson@canonical.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: David Henningsson Cc: alsa-devel@alsa-project.org, fengguang.wu@intel.com, pierre-louis.bossart@linux.intel.com List-Id: alsa-devel@alsa-project.org At Mon, 18 Feb 2013 14:11:12 +0100, David Henningsson wrote: > > Previously, it was possible to read the eld data of the previous > monitor connected. This should not be allowed. > > Also refactor the function slightly. > > Signed-off-by: David Henningsson > --- > sound/pci/hda/patch_hdmi.c | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c > index 32adaa6..9236cdb 100644 > --- a/sound/pci/hda/patch_hdmi.c > +++ b/sound/pci/hda/patch_hdmi.c > @@ -343,14 +343,17 @@ static int hdmi_eld_ctl_info(struct snd_kcontrol *kcontrol, > struct snd_ctl_elem_info *uinfo) > { > struct hda_codec *codec = snd_kcontrol_chip(kcontrol); > - struct hdmi_spec *spec; > + struct hdmi_spec *spec = codec->spec; > + struct hdmi_eld *eld; > int pin_idx; > > - spec = codec->spec; > uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; > > pin_idx = kcontrol->private_value; > - uinfo->count = spec->pins[pin_idx].sink_eld.eld_size; > + eld = &spec->pins[pin_idx].sink_eld; > + > + if (eld->eld_valid) > + uinfo->count = eld->eld_valid ? eld->eld_size : 0; You don't have to check eld->eld_valid twice. Takashi