Skip to content

Commit 4029a29

Browse files
crojewsk-intelgregkh
authored andcommitted
ASoC: Intel: Skylake: Shield against no-NHLT configurations
commit 9e6c382 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 <cezary.rojewski@intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200305145314.32579-5-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org> Cc: <stable@vger.kernel.org> # 5.4.x Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 754df2d commit 4029a29

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

sound/soc/intel/skylake/skl-nhlt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ void skl_nhlt_remove_sysfs(struct skl_dev *skl)
182182
{
183183
struct device *dev = &skl->pci->dev;
184184

185-
sysfs_remove_file(&dev->kobj, &dev_attr_platform_id.attr);
185+
if (skl->nhlt)
186+
sysfs_remove_file(&dev->kobj, &dev_attr_platform_id.attr);
186187
}
187188

188189
/*

sound/soc/intel/skylake/skl.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,9 @@ static int skl_clock_device_register(struct skl_dev *skl)
632632
struct platform_device_info pdevinfo = {NULL};
633633
struct skl_clk_pdata *clk_pdata;
634634

635+
if (!skl->nhlt)
636+
return 0;
637+
635638
clk_pdata = devm_kzalloc(&skl->pci->dev, sizeof(*clk_pdata),
636639
GFP_KERNEL);
637640
if (!clk_pdata)
@@ -1090,7 +1093,8 @@ static int skl_probe(struct pci_dev *pci,
10901093
out_clk_free:
10911094
skl_clock_device_unregister(skl);
10921095
out_nhlt_free:
1093-
intel_nhlt_free(skl->nhlt);
1096+
if (skl->nhlt)
1097+
intel_nhlt_free(skl->nhlt);
10941098
out_free:
10951099
skl_free(bus);
10961100

@@ -1139,7 +1143,8 @@ static void skl_remove(struct pci_dev *pci)
11391143
skl_dmic_device_unregister(skl);
11401144
skl_clock_device_unregister(skl);
11411145
skl_nhlt_remove_sysfs(skl);
1142-
intel_nhlt_free(skl->nhlt);
1146+
if (skl->nhlt)
1147+
intel_nhlt_free(skl->nhlt);
11431148
skl_free(bus);
11441149
dev_set_drvdata(&pci->dev, NULL);
11451150
}

0 commit comments

Comments
 (0)