Commit 776cb3b8 authored by Amadeusz Sławiński's avatar Amadeusz Sławiński Committed by Mark Brown

ASoC: Intel: Skylake: Initialize lists before access so they are safe to use

If skl_probe_work() was not run driver ends up dereferencing NULL
pointer when operating on lists in skl_platform_unregister().
To fix this initialize lists in skl_create(). Also run
cancel_work_sync() before all cleanup functions, so we don't end up
unnecessarily running probe work.

Easily reproducible with:
while true; do modprobe snd_soc_skl; rmmod snd_soc_skl; done
(with the assumption that relevant drivers are added to blacklist on
system boot)
Signed-off-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent d5fcaaba
...@@ -1498,9 +1498,6 @@ int skl_platform_register(struct device *dev) ...@@ -1498,9 +1498,6 @@ int skl_platform_register(struct device *dev)
struct hdac_bus *bus = dev_get_drvdata(dev); struct hdac_bus *bus = dev_get_drvdata(dev);
struct skl *skl = bus_to_skl(bus); struct skl *skl = bus_to_skl(bus);
INIT_LIST_HEAD(&skl->ppl_list);
INIT_LIST_HEAD(&skl->bind_list);
skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai), skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai),
GFP_KERNEL); GFP_KERNEL);
if (!skl->dais) { if (!skl->dais) {
......
...@@ -438,7 +438,6 @@ static int skl_free(struct hdac_bus *bus) ...@@ -438,7 +438,6 @@ static int skl_free(struct hdac_bus *bus)
snd_hdac_ext_bus_exit(bus); snd_hdac_ext_bus_exit(bus);
cancel_work_sync(&skl->probe_work);
if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
snd_hdac_i915_exit(bus); snd_hdac_i915_exit(bus);
...@@ -867,6 +866,9 @@ static int skl_create(struct pci_dev *pci, ...@@ -867,6 +866,9 @@ static int skl_create(struct pci_dev *pci,
hbus = skl_to_hbus(skl); hbus = skl_to_hbus(skl);
bus = skl_to_bus(skl); bus = skl_to_bus(skl);
INIT_LIST_HEAD(&skl->ppl_list);
INIT_LIST_HEAD(&skl->bind_list);
#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) #if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC)
ext_ops = snd_soc_hdac_hda_get_ops(); ext_ops = snd_soc_hdac_hda_get_ops();
#endif #endif
...@@ -1116,6 +1118,7 @@ static void skl_remove(struct pci_dev *pci) ...@@ -1116,6 +1118,7 @@ static void skl_remove(struct pci_dev *pci)
struct hdac_bus *bus = pci_get_drvdata(pci); struct hdac_bus *bus = pci_get_drvdata(pci);
struct skl *skl = bus_to_skl(bus); struct skl *skl = bus_to_skl(bus);
cancel_work_sync(&skl->probe_work);
release_firmware(skl->tplg); release_firmware(skl->tplg);
pm_runtime_get_noresume(&pci->dev); pm_runtime_get_noresume(&pci->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment