Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp404587pxu; Tue, 1 Dec 2020 14:25:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLSMCpDpL3QGzJ35b331iEkXdHvS4JhlJBLyEhCvSBhJ+b5eHUPg85viaQcdHAXzc7FfYW X-Received: by 2002:a50:d745:: with SMTP id i5mr5426832edj.166.1606861505935; Tue, 01 Dec 2020 14:25:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861505; cv=none; d=google.com; s=arc-20160816; b=opQc+TU1L20cafj9Oung3CXxE31LFKvOrxD4gYLlm+FtVFhvKVVmM7U7i6MPqr02xj LLLGbEPtcCuhuyjrb7gEn5ws6UGprmGei4cTYp799lKQ/L47oQsm28Xer13BiOmCuToF ZzJ56oDpkl/+3iPLchR5xS6Ybdtc6diKIN26rpoc8nr+i1EIIc47vFA2hVW5F4lsKfRf GrJKNgllEGFNUzX/2V+2dcpP0YzAIGKvkIb9bBG+Eo0LHs7sOKtww1jA01BVrg1/oHcM rTsxg0jrAa7hJi5StT4UJDcmnGnye2Pf7xhH8YA3Y942uFZAxGrFUX10HvLwg19T2ZOH j6Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=taThS4ro9LjGf75p+l/ZO1Gkv8o4WuE9GhU4PorJT4o=; b=gxgJcps27VYMEu+EIbxCiuxi3SY+JLtps0a57bPxcAUSkwdlbH4i32Z7Q6hdfr19fF vQZnGUuxP1TuZ3TaRsctqJr156dBR1PKFtKzE+e/kivyhzOf0+bNVR+YjCXqZvqfncnm lb5E7rllaepCe8ukcp0Fv1kKJ/FdqOqNwAp0/Y0770JfJ9dozOGFyrNhW4113r2xbsAh CfCEXPTzX8tTZybMHzZonSYtZefHlYjbjeGBZbzINRVNo4TyzTJ1nI3d42aJ89/5UiSx qrI1shfY1dVNlOtab3hIcPgX3zVTBfGguf39mNVHur5w7RVTGFb6STbNI2Qm/0I/k8j7 AMYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TLJJ9D8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si777447edm.399.2020.12.01.14.24.43; Tue, 01 Dec 2020 14:25:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TLJJ9D8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389338AbgLAJIw (ORCPT + 99 others); Tue, 1 Dec 2020 04:08:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:44728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729429AbgLAJHk (ORCPT ); Tue, 1 Dec 2020 04:07:40 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5C76620656; Tue, 1 Dec 2020 09:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813620; bh=S2DkrXiMs50rzeOWr8r3U1Ajd0op23TcWMczb1ZsiwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TLJJ9D8qC+vHLrDNa++pUrLJqhNd4ZThIo0czIJkhMN5zbdO6bgTZ1xTbOV1N8HO+ 8WGCW5qhYmwccPgz1GzdNjm2MPsbrFnIS2ValwSQLK5Dx+k7jPuTq9lElj/LpvOTcg pi14vMByUS5raLQ+ouqQi7mzNiX2wJ2Bc0YD0EV4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "alsa-devel@alsa-project.org, broonie@kernel.org, tiwai@suse.com, pierre-louis.bossart@linux.intel.com, mateusz.gorski@linux.intel.com, Cezary Rojewski" , Pierre-Louis Bossart , Mark Brown , Cezary Rojewski Subject: [PATCH 5.4 94/98] ASoC: Intel: Skylake: Shield against no-NHLT configurations Date: Tue, 1 Dec 2020 09:54:11 +0100 Message-Id: <20201201084659.669425413@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084652.827177826@linuxfoundation.org> References: <20201201084652.827177826@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cezary Rojewski commit 9e6c382f5a6161eb55115fb56614b9827f2e7da3 upstream. Some configurations expose no NHLT table at all within their /sys/firmware/acpi/tables. To prevent NULL-dereference errors from occurring, adjust probe flow and append additional safety checks in functions involved in NHLT lifecycle. Signed-off-by: Cezary Rojewski Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200305145314.32579-5-cezary.rojewski@intel.com Signed-off-by: Mark Brown Cc: # 5.4.x Signed-off-by: Greg Kroah-Hartman --- sound/soc/intel/skylake/skl-nhlt.c | 3 ++- sound/soc/intel/skylake/skl.c | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) --- a/sound/soc/intel/skylake/skl-nhlt.c +++ b/sound/soc/intel/skylake/skl-nhlt.c @@ -182,7 +182,8 @@ void skl_nhlt_remove_sysfs(struct skl_de { struct device *dev = &skl->pci->dev; - sysfs_remove_file(&dev->kobj, &dev_attr_platform_id.attr); + if (skl->nhlt) + sysfs_remove_file(&dev->kobj, &dev_attr_platform_id.attr); } /* --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -632,6 +632,9 @@ static int skl_clock_device_register(str struct platform_device_info pdevinfo = {NULL}; struct skl_clk_pdata *clk_pdata; + if (!skl->nhlt) + return 0; + clk_pdata = devm_kzalloc(&skl->pci->dev, sizeof(*clk_pdata), GFP_KERNEL); if (!clk_pdata) @@ -1090,7 +1093,8 @@ out_dsp_free: out_clk_free: skl_clock_device_unregister(skl); out_nhlt_free: - intel_nhlt_free(skl->nhlt); + if (skl->nhlt) + intel_nhlt_free(skl->nhlt); out_free: skl_free(bus); @@ -1139,7 +1143,8 @@ static void skl_remove(struct pci_dev *p skl_dmic_device_unregister(skl); skl_clock_device_unregister(skl); skl_nhlt_remove_sysfs(skl); - intel_nhlt_free(skl->nhlt); + if (skl->nhlt) + intel_nhlt_free(skl->nhlt); skl_free(bus); dev_set_drvdata(&pci->dev, NULL); }