From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762921AbdDSMQj (ORCPT ); Wed, 19 Apr 2017 08:16:39 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:44546 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762888AbdDSMQh (ORCPT ); Wed, 19 Apr 2017 08:16:37 -0400 From: Colin King To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Vinod Koul , Jeeja KP , Jayachandran B , "Subhransu S . Prusty" , Dharageswari R , Pardha Saradhi K , Yong Zhi , alsa-devel@alsa-project.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: Intel: Skylake: fix dereference before NULL check on ebus Date: Wed, 19 Apr 2017 13:16:13 +0100 Message-Id: <20170419121613.12353-1-colin.king@canonical.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King ebus is being NULL checked however it is being dereferenced earlier on the assignment bus = ebus_to_hbus(ebus). Fix this by moving the assignment to after the NULL check on ebus to avoid a NULL pointer dereference error. Fixes: c5a76a246989c8 ("ASoC: Intel: Skylake: Add shutdown callback") Signed-off-by: Colin Ian King --- sound/soc/intel/skylake/skl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index 0c57d4eaae3a..21369f60fbaa 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -818,7 +818,7 @@ static int skl_probe(struct pci_dev *pci, static void skl_shutdown(struct pci_dev *pci) { struct hdac_ext_bus *ebus = pci_get_drvdata(pci); - struct hdac_bus *bus = ebus_to_hbus(ebus); + struct hdac_bus *bus; struct hdac_stream *s; struct hdac_ext_stream *stream; struct skl *skl; @@ -826,6 +826,7 @@ static void skl_shutdown(struct pci_dev *pci) if (ebus == NULL) return; + bus = ebus_to_hbus(ebus); skl = ebus_to_skl(ebus); if (skl->init_failed) -- 2.11.0