From patchwork Thu Jan 21 17:51:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 368596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAAFCC433E0 for ; Thu, 21 Jan 2021 17:53:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D70422CE3 for ; Thu, 21 Jan 2021 17:53:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389176AbhAURwk (ORCPT ); Thu, 21 Jan 2021 12:52:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389139AbhAURwh (ORCPT ); Thu, 21 Jan 2021 12:52:37 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BAC6C06174A for ; Thu, 21 Jan 2021 09:51:54 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id w1so3820512ejf.11 for ; Thu, 21 Jan 2021 09:51:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=51VcyZ0wcuGuW2m213F8YE94gBtxdpp+DVm+1XUV/kc=; b=H5RbvKJzOAZSzZttqk+4D6J5otSROP5TEODNUwb21iPJKfP+Ab3VInvWrEmmIXc51D kT4vXcIGucGm/xDXGd5766NQhpstAG53Q8NLEmg4cvuF7NJn7NI2aqKPPNarNCatpphL n04UttoRPSTulyYrFLysFiGhqiFnUg2Vsf0CI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=51VcyZ0wcuGuW2m213F8YE94gBtxdpp+DVm+1XUV/kc=; b=lReJemOQbmPLos30Q7YsybZwVDtqX+h1AaP58o0kj0hdkkDT1ZPWiOppRfRVtT8E+Q dzuq6qyiPUUSopYMEuFLc4xuXEQnPhQlxkAwyQBQ+HxYxfdV6KN2VTXlhH2oEhrMub9d Ypo086MqqLj1rjg5MZcE+sLkmc9U9dXcZGdAaOZEfqARTtrGcitvHNYhjHgD8VW4ir0O s914zAJomYyU9R1KiKHrgjtpGs2/6YEnHLC7IcAlhO5+J2RncLNFfK1rMUxazB8j+Pms G+DtUMuK3234or1umbTcILY1H9WSsMoA70QQMFs6c9cyJCdT+HEuaBy68aCAPLt82Uec LOiQ== X-Gm-Message-State: AOAM531yFHKAmWcQpYFi0f7QIldcRDWA66j2VEDdNL0MJNfSZ+kOd/yT JogvzS58Kos+nS4O2/9RVlYoIQ== X-Google-Smtp-Source: ABdhPJx+D8/Miw7niFfErjOQWn8sH7EaMNhkJL7TJSDo4zIFgNNDjogLT0p7KxD+/CzpFUu1z+e5Lw== X-Received: by 2002:a17:906:4893:: with SMTP id v19mr421764ejq.454.1611251513363; Thu, 21 Jan 2021 09:51:53 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id w16sm3232349edv.4.2021.01.21.09.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 09:51:52 -0800 (PST) From: Ricardo Ribalda To: Andy Shevchenko , Cezary Rojewski , Pierre-Louis Bossart , Liam Girdwood , Jie Yang , Mark Brown , Jaroslav Kysela , Takashi Iwai , Mateusz Gorski , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Lukasz Majczak Cc: Ricardo Ribalda , stable@vger.kernel.org Subject: [PATCH v3 1/2] ASoC: Intel: Skylake: skl-topology: Fix OOPs ib skl_tplg_complete Date: Thu, 21 Jan 2021 18:51:50 +0100 Message-Id: <20210121175151.139111-1-ribalda@chromium.org> X-Mailer: git-send-email 2.30.0.296.g2bfb1c46d8-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org If dobj->control is not initialized we end up in an OOPs during skl_tplg_complete: [ 26.553358] BUG: kernel NULL pointer dereference, address: 0000000000000078 [ 26.561151] #PF: supervisor read access in kernel mode [ 26.566897] #PF: error_code(0x0000) - not-present page [ 26.572642] PGD 0 P4D 0 [ 26.575479] Oops: 0000 [#1] PREEMPT SMP PTI [ 26.580158] CPU: 2 PID: 2082 Comm: udevd Tainted: G C 5.4.81 #4 [ 26.588232] Hardware name: HP Soraka/Soraka, BIOS Google_Soraka.10431.106.0 12/03/2019 [ 26.597082] RIP: 0010:skl_tplg_complete+0x70/0x144 [snd_soc_skl] Cc: Fixes: 2d744ecf2b98 ("ASoC: Intel: Skylake: Automatic DMIC format configuration according to information from NHL") Tested-by: Lukasz Majczak Reviewed-by: Andy Shevchenko Reviewed-by: Cezary Rojewski Signed-off-by: Ricardo Ribalda --- v3: order local variables by length sound/soc/intel/skylake/skl-topology.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index ae466cd59292..ffd37aaecdf1 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -3619,15 +3619,16 @@ static void skl_tplg_complete(struct snd_soc_component *component) list_for_each_entry(dobj, &component->dobj_list, list) { struct snd_kcontrol *kcontrol = dobj->control.kcontrol; - struct soc_enum *se = - (struct soc_enum *)kcontrol->private_value; - char **texts = dobj->control.dtexts; + struct soc_enum *se; char chan_text[4]; + char **texts; - if (dobj->type != SND_SOC_DOBJ_ENUM || - dobj->control.kcontrol->put != - skl_tplg_multi_config_set_dmic) + if (dobj->type != SND_SOC_DOBJ_ENUM || !kcontrol || + kcontrol->put != skl_tplg_multi_config_set_dmic) continue; + + se = (struct soc_enum *)kcontrol->private_value; + texts = dobj->control.dtexts; sprintf(chan_text, "c%d", mach->mach_params.dmic_num); for (i = 0; i < se->items; i++) {