WSL2-Linux-Kernel/sound/pci/hda
Kai Vehmanen e81478bbe7 ALSA: hda: fix general protection fault in azx_runtime_idle
Fix a corner case between PCI device driver remove callback and
runtime PM idle callback.

Following sequence of events can happen:
  - at azx_create, context is allocated with devm_kzalloc() and
    stored as pci_set_drvdata()
  - user-space requests to unbind audio driver
  - dd.c:__device_release_driver() calls PCI remove
  - pci-driver.c:pci_device_remove() calls the audio
    driver azx_remove() callback and this is completed
  - pci-driver.c:pm_runtime_put_sync() leads to a call
    to rpm_idle() which again calls azx_runtime_idle()
  - the azx context object, as returned by dev_get_drvdata(),
    is no longer valid
  -> access fault in azx_runtime_idle when executing
	struct snd_card *card = dev_get_drvdata(dev);
	chip = card->private_data;
	if (chip->disabled || hda->init_failed)

This was discovered by i915_module_load test with 5.15.0 based
linux-next tree.

Example log caught by i915_module_load test with linux-next
https://intel-gfx-ci.01.org/tree/linux-next/

<4> [264.038232] general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b73f0: 0000 [#1] PREEMPT SMP NOPTI
<4> [264.038248] CPU: 0 PID: 5374 Comm: i915_module_loa Not tainted 5.15.0-next-20211109-gc8109c2ba35e-next-20211109 #1
[...]
<4> [264.038267] RIP: 0010:azx_runtime_idle+0x12/0x60 [snd_hda_intel]
[...]
<4> [264.038355] Call Trace:
<4> [264.038359]  <TASK>
<4> [264.038362]  __rpm_callback+0x3d/0x110
<4> [264.038371]  rpm_idle+0x27f/0x380
<4> [264.038376]  __pm_runtime_idle+0x3b/0x100
<4> [264.038382]  pci_device_remove+0x6d/0xa0
<4> [264.038388]  device_release_driver_internal+0xef/0x1e0
<4> [264.038395]  unbind_store+0xeb/0x120
<4> [264.038400]  kernfs_fop_write_iter+0x11a/0x1c0

Fix the issue by setting drvdata to NULL at end of azx_remove().

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211110210307.1172004-1-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-11-10 22:48:31 +01:00
..
Kconfig ALSA: hda/cirrus: Move CS8409 HDA bridge to separate module 2021-08-12 13:41:36 +02:00
Makefile ALSA: hda/cs8409: Move arrays of configuration to a new file 2021-08-12 13:41:39 +02:00
ca0132_regs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 32 2019-05-24 17:27:10 +02:00
hda_auto_parser.c ALSA: hda: Allow model option to specify PCI SSID alias 2021-08-23 10:59:13 +02:00
hda_auto_parser.h ALSA: hda/cirrus: Increase AUTO_CFG_MAX_INS from 8 to 18 2021-03-07 09:17:30 +01:00
hda_beep.c ALSA: Use fallthrough pseudo-keyword 2020-07-09 13:01:29 +02:00
hda_beep.h ALSA: hda - Use standard device registration for beep 2019-01-29 18:28:09 +01:00
hda_bind.c ALSA: hda: intel: Allow repeatedly probing on codec configuration errors 2021-10-07 09:15:22 +02:00
hda_codec.c ALSA: hda: intel: Allow repeatedly probing on codec configuration errors 2021-10-07 09:15:22 +02:00
hda_controller.c ALSA: hda: intel: Allow repeatedly probing on codec configuration errors 2021-10-07 09:15:22 +02:00
hda_controller.h ALSA: hda: intel: Allow repeatedly probing on codec configuration errors 2021-10-07 09:15:22 +02:00
hda_controller_trace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hda_eld.c ALSA: Convert strlcpy to strscpy when return value is unused 2021-01-08 09:30:05 +01:00
hda_generic.c Merge branch 'for-linus' into for-next 2021-08-17 09:46:27 +02:00
hda_generic.h ALSA: hda: Nuke unused reboot_notify callback 2021-08-14 08:39:38 +02:00
hda_hwdep.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 32 2019-05-24 17:27:10 +02:00
hda_intel.c ALSA: hda: fix general protection fault in azx_runtime_idle 2021-11-10 22:48:31 +01:00
hda_intel.h ALSA: hda: intel: Allow repeatedly probing on codec configuration errors 2021-10-07 09:15:22 +02:00
hda_intel_trace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hda_jack.c ALSA: add virtio sound driver 2021-03-07 09:16:24 +01:00
hda_jack.h ALSA: hda - bind headset buttons to the headphone jack 2021-03-05 15:18:24 +01:00
hda_local.h ALSA: hda: Suspend codec at shutdown 2021-08-14 08:39:27 +02:00
hda_proc.c ALSA: hda/proc - print DP-MST connections 2020-12-08 20:04:33 +01:00
hda_sysfs.c ALSA: hda: Fix regressions on clear and reconfig sysfs 2020-12-10 19:55:35 +01:00
hda_tegra.c ALSA: hda: Add IRQ check for platform_get_irq() 2021-06-22 16:12:03 +02:00
hp_x360_helper.c ALSA: hda/realtek - Fixup for HP x360 laptops with B&O speakers 2018-05-29 22:33:37 +02:00
ideapad_s740_helper.c ALSA: hda/realtek: Add quirk for Lenovo Ideapad S740 2021-04-16 10:12:50 +02:00
patch_analog.c ALSA: hda/analog - Sink ad198x_shutup() and shuffle CONFIG_PM guards 2021-08-18 07:51:09 +02:00
patch_ca0110.c ALSA: hda: Unify get_response handling 2019-12-13 14:36:52 +01:00
patch_ca0132.c ALSA: hda: Nuke unused reboot_notify callback 2021-08-14 08:39:38 +02:00
patch_cirrus.c ALSA: hda/cirrus: Move CS8409 HDA bridge to separate module 2021-08-12 13:41:36 +02:00
patch_cmedia.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 32 2019-05-24 17:27:10 +02:00
patch_conexant.c ALSA: hda: Nuke unused reboot_notify callback 2021-08-14 08:39:38 +02:00
patch_cs8409-tables.c ALSA: hda/cs8409: Unmute/Mute codec when stream starts/stops 2021-08-12 13:42:01 +02:00
patch_cs8409.c ALSA: hda/cs8409: Setup Dolphin Headset Mic as Phantom Jack 2021-09-16 12:24:46 +02:00
patch_cs8409.h ALSA: hda/cs8409: Ensure Type Detection is only run on startup when necessary 2021-08-27 22:35:34 +02:00
patch_hdmi.c Merge branch 'for-linus' into for-next 2021-08-02 09:04:48 +02:00
patch_realtek.c ALSA: hda/realtek: Add quirk for HP EliteBook 840 G7 mute LED 2021-11-10 15:44:18 +01:00
patch_si3054.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 32 2019-05-24 17:27:10 +02:00
patch_sigmatel.c ALSA: hda/sigmatel - Sink stac_shutup() into stac_suspend() 2021-08-18 07:51:02 +02:00
patch_via.c ALSA: hda/via: Apply runtime PM workaround for ASUS B23E 2021-08-17 08:02:44 +02:00
thinkpad_helper.c ALSA: HDA - remove the custom implementation for the audio LED trigger 2021-03-30 15:35:15 +02:00