From: Takashi Iwai Subject: Re: ALSA: hda/realtek - Allow NULL bus->pci Date: Wed, 08 Oct 2014 12:12:22 +0200 Message-ID: References: <20141008093246.GA4690@mwanda> 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 144AD260451 for ; Wed, 8 Oct 2014 12:12:23 +0200 (CEST) In-Reply-To: <20141008093246.GA4690@mwanda> 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: Dan Carpenter Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Wed, 8 Oct 2014 12:32:46 +0300, Dan Carpenter wrote: > > Hello Takashi Iwai, > > The patch 5100cd07d43a: "ALSA: hda/realtek - Allow NULL bus->pci" > from Feb 15, 2014, leads to the following static checker warning: > > sound/pci/hda/patch_realtek.c:5371 patch_alc269() > warn: variable dereferenced before check 'codec->bus->pci' (see line 5364) > > sound/pci/hda/patch_realtek.c > 5363 if (has_cdefine_beep(codec)) > ^^^^^ > We actually dereference "codec->bus->pci" inside the call to > has_cdefine_beep(). Indeed. I fixed snd_pci_quirk_lookup() itself to accept NULL pointer as a generic fix in below. Thanks! Takashi -- 8< -- From: Takashi Iwai Subject: [PATCH] ALSA: Allow pass NULL dev for snd_pci_quirk_lookup() Add a NULL check in snd_pci_quirk_lookup() so that NULL can be passed as a pci_dev pointer. This fixes the possible NULL dereferences in HD-audio drivers. Reported-by: Dan Carpenter Signed-off-by: Takashi Iwai --- sound/core/misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/core/misc.c b/sound/core/misc.c index 30e027ecf4da..f2e8226c88fb 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c @@ -145,6 +145,8 @@ EXPORT_SYMBOL(snd_pci_quirk_lookup_id); const struct snd_pci_quirk * snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list) { + if (!pci) + return NULL; return snd_pci_quirk_lookup_id(pci->subsystem_vendor, pci->subsystem_device, list); -- 2.1.2