From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Takashi Iwai <tiwai@suse.de>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.6 074/106] ALSA: hda: Release resources at error in delayed probe
Date: Fri, 1 May 2020 15:23:47 +0200 [thread overview]
Message-ID: <20200501131552.865351475@linuxfoundation.org> (raw)
In-Reply-To: <20200501131543.421333643@linuxfoundation.org>
From: Takashi Iwai <tiwai@suse.de>
[ Upstream commit 2393e7555b531a534152ffe7bfd1862cacedaacb ]
snd-hda-intel driver handles the most of its probe task in the delayed
work (either via workqueue or via firmware loader). When an error
happens in the later delayed probe, we can't deregister the device
itself because the probe callback already returned success and the
device was bound. So, for now, we set hda->init_failed flag and make
the rest untouched until the device gets really unbound.
However, this leaves the device up running, keeping the resources
without any use that prevents other operations.
In this patch, we release the resources at first when a probe error
happens in the delayed probe stage, but keeps the top-level object, so
that the PM and other ops can still refer to the object itself.
Also for simplicity, snd_hda_intel object is allocated via devm, so
that we can get rid of the explicit kfree calls.
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207043
Link: https://lore.kernel.org/r/20200413082034.25166-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/pci/hda/hda_intel.c | 29 ++++++++++++++++-------------
sound/pci/hda/hda_intel.h | 1 +
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index af21e9583c0d3..3047dc357b38b 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1203,10 +1203,8 @@ static void azx_vs_set_state(struct pci_dev *pci,
if (!disabled) {
dev_info(chip->card->dev,
"Start delayed initialization\n");
- if (azx_probe_continue(chip) < 0) {
+ if (azx_probe_continue(chip) < 0)
dev_err(chip->card->dev, "initialization error\n");
- hda->init_failed = true;
- }
}
} else {
dev_info(chip->card->dev, "%s via vga_switcheroo\n",
@@ -1339,12 +1337,15 @@ static int register_vga_switcheroo(struct azx *chip)
/*
* destructor
*/
-static int azx_free(struct azx *chip)
+static void azx_free(struct azx *chip)
{
struct pci_dev *pci = chip->pci;
struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
struct hdac_bus *bus = azx_bus(chip);
+ if (hda->freed)
+ return;
+
if (azx_has_pm_runtime(chip) && chip->running)
pm_runtime_get_noresume(&pci->dev);
chip->running = 0;
@@ -1388,9 +1389,8 @@ static int azx_free(struct azx *chip)
if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT)
snd_hdac_i915_exit(bus);
- kfree(hda);
- return 0;
+ hda->freed = 1;
}
static int azx_dev_disconnect(struct snd_device *device)
@@ -1406,7 +1406,8 @@ static int azx_dev_disconnect(struct snd_device *device)
static int azx_dev_free(struct snd_device *device)
{
- return azx_free(device->device_data);
+ azx_free(device->device_data);
+ return 0;
}
#ifdef SUPPORT_VGA_SWITCHEROO
@@ -1773,7 +1774,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
if (err < 0)
return err;
- hda = kzalloc(sizeof(*hda), GFP_KERNEL);
+ hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL);
if (!hda) {
pci_disable_device(pci);
return -ENOMEM;
@@ -1814,7 +1815,6 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
err = azx_bus_init(chip, model[dev]);
if (err < 0) {
- kfree(hda);
pci_disable_device(pci);
return err;
}
@@ -2339,13 +2339,16 @@ static int azx_probe_continue(struct azx *chip)
pm_runtime_put_autosuspend(&pci->dev);
out_free:
- if (err < 0 || !hda->need_i915_power)
+ if (err < 0) {
+ azx_free(chip);
+ return err;
+ }
+
+ if (!hda->need_i915_power)
display_power(chip, false);
- if (err < 0)
- hda->init_failed = 1;
complete_all(&hda->probe_wait);
to_hda_bus(bus)->bus_probing = 0;
- return err;
+ return 0;
}
static void azx_remove(struct pci_dev *pci)
diff --git a/sound/pci/hda/hda_intel.h b/sound/pci/hda/hda_intel.h
index 2acfff3da1a04..3fb119f090408 100644
--- a/sound/pci/hda/hda_intel.h
+++ b/sound/pci/hda/hda_intel.h
@@ -27,6 +27,7 @@ struct hda_intel {
unsigned int use_vga_switcheroo:1;
unsigned int vga_switcheroo_registered:1;
unsigned int init_failed:1; /* delayed init failed */
+ unsigned int freed:1; /* resources already released */
bool need_i915_power:1; /* the hda controller needs i915 power */
};
--
2.20.1
next prev parent reply other threads:[~2020-05-01 13:46 UTC|newest]
Thread overview: 115+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-01 13:22 [PATCH 5.6 000/106] 5.6.9-rc1 review Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 001/106] ubifs: Fix ubifs_tnc_lookup() usage in do_kill_orphans() Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 002/106] printk: queue wake_up_klogd irq_work only if per-CPU areas are ready Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 003/106] ASoC: stm32: sai: fix sai probe Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 004/106] usb: dwc3: gadget: Do link recovery for SS and SSP Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 005/106] ARM: dts: bcm283x: Add cells encoding format to firmware bus Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 006/106] kbuild: fix DT binding schema rule again to avoid needless rebuilds Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 007/106] usb: gadget: udc: bdc: Remove unnecessary NULL checks in bdc_req_complete Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 008/106] usb: gadget: udc: atmel: Fix vbus disconnect handling Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 009/106] afs: Make record checking use TASK_UNINTERRUPTIBLE when appropriate Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 010/106] afs: Fix to actually set AFS_SERVER_FL_HAVE_EPOCH Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 011/106] iio:ad7797: Use correct attribute_group Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 012/106] iio: imu: st_lsm6dsx: fix read misalignment on untagged FIFO Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 013/106] iio: imu: st_lsm6dsx: specify slave odr in slv_odr Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 014/106] propagate_one(): mnt_set_mountpoint() needs mount_lock Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 015/106] counter: 104-quad-8: Add lock guards - generic interface Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 016/106] s390/ftrace: fix potential crashes when switching tracers Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 017/106] ASoC: q6dsp6: q6afe-dai: add missing channels to MI2S DAIs Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 018/106] iwlwifi: actually check allocated conf_tlv pointer Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 019/106] ASoC: samsung: s3c24xx-i2s: Fix build after removal of DAI suspend/resume Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 020/106] ASoC: tas571x: disable regulators on failed probe Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 021/106] ASoC: meson: axg-card: fix codec-to-codec link setup Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 022/106] ASoC: wm8960: Fix wrong clock after suspend & resume Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 023/106] drivers: soc: xilinx: fix firmware driver Kconfig dependency Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 024/106] nfsd: memory corruption in nfsd4_lock() Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 025/106] ARM: dts: OMAP3: disable RNG on N950/N9 Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 5.6 026/106] bpf: Forbid XADD on spilled pointers for unprivileged users Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 027/106] brcmfmac: add stub for monitor interface xmit Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 028/106] i2c: altera: use proper variable to hold errno Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 029/106] hwmon: (drivetemp) Use drivetemps true module name in Kconfig section Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 030/106] clk: asm9260: fix __clk_hw_register_fixed_rate_with_accuracy typo Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 031/106] rtw88: avoid unused function warnings Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 032/106] hwmon: (drivetemp) Return -ENODATA for invalid temperatures Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 033/106] rxrpc: Fix DATA Tx to disable nofrag for UDP on AF_INET6 socket Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 034/106] netfilter: nf_tables: reintroduce the NFT_SET_CONCAT flag Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 035/106] efi/x86: Dont remap text<->rodata gap read-only for mixed mode Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 036/106] net/cxgb4: Check the return from t4_query_params properly Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 037/106] tipc: fix incorrect increasing of link window Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 038/106] xfs: acquire superblock freeze protection on eofblocks scans Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 039/106] svcrdma: Fix trace point use-after-free race Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 040/106] svcrdma: Fix leak of svc_rdma_recv_ctxt objects Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 041/106] net/mlx5e: Dont trigger IRQ multiple times on XSK wakeup to avoid WQ overruns Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 042/106] net/mlx5e: Get the latest values from counters in switchdev mode Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 043/106] PCI: Avoid ASMedia XHCI USB PME# from D0 defect Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 044/106] PCI: Add Zhaoxin Vendor ID Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 045/106] PCI: Add ACS quirk for Zhaoxin multi-function devices Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 046/106] PCI: Add ACS quirk for Zhaoxin Root/Downstream Ports Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 047/106] PCI: Move Apex Edge TPU class quirk to fix BAR assignment Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 048/106] ARM: dts: bcm283x: Disable dsi0 node Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 049/106] cpumap: Avoid warning when CONFIG_DEBUG_PER_CPU_MAPS is enabled Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 050/106] s390/pci: do not set affinity for floating irqs Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 051/106] remoteproc: mtk_scp: use dma_addr_t for DMA API Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 052/106] net/mlx5: Fix failing fw tracer allocation on s390 Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 053/106] sched/core: Fix reset-on-fork from RT with uclamp Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 054/106] perf/core: fix parent pid/tid in task exit events Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 055/106] netfilter: nat: fix error handling upon registering inet hook Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 056/106] PM: sleep: core: Switch back to async_schedule_dev() Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 057/106] blk-iocost: Fix error on iocost_ioc_vrate_adj Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 058/106] um: ensure `make ARCH=um mrproper` removes arch/$(SUBARCH)/include/generated/ Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 059/106] bpf: Fix handling of XADD on BTF memory Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 060/106] bpf, x86: Fix encoding for lower 8-bit registers in BPF_STX BPF_B Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 061/106] bpf, x86_32: Fix incorrect encoding in BPF_LDX zero-extension Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 062/106] bpf, x86_32: Fix clobbering of dst for BPF_JSET Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 063/106] bpf, x86_32: Fix logic error in BPF_LDX zero-extension Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 064/106] bpf: Propagate expected_attach_type when verifying freplace programs Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 065/106] selftests/bpf: Fix a couple of broken test_btf cases Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 066/106] mm: shmem: disable interrupt when acquiring info->lock in userfaultfd_copy path Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 067/106] xfs: clear PF_MEMALLOC before exiting xfsaild thread Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 068/106] libbpf: Initialize *nl_pid so gcc 10 is happy Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 069/106] net: fec: set GPR bit on suspend by DT configuration Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 070/106] x86: hyperv: report value of misc_features Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 071/106] signal: check sig before setting info in kill_pid_usb_asyncio Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 072/106] afs: Fix length of dump of bad YFSFetchStatus record Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 073/106] xfs: fix partially uninitialized structure in xfs_reflink_remap_extent Greg Kroah-Hartman
2020-05-01 13:23 ` Greg Kroah-Hartman [this message]
2020-05-01 13:23 ` [PATCH 5.6 075/106] ALSA: hda: Keep the controller initialization even if no codecs found Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 076/106] ALSA: hda: Explicitly permit using autosuspend if runtime PM is supported Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 077/106] drm/amdgpu: fix wrong vram lost counter increment V2 Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 078/106] scsi: target: fix PR IN / READ FULL STATUS for FC Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 079/106] scsi: target: tcmu: reset_ring should reset TCMU_DEV_BIT_BROKEN Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 080/106] objtool: Fix CONFIG_UBSAN_TRAP unreachable warnings Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 081/106] objtool: Support Clang non-section symbols in ORC dump Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 082/106] xen/xenbus: ensure xenbus_map_ring_valloc() returns proper grant status Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 083/106] ALSA: hda: call runtime_allow() for all hda controllers Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 084/106] net: stmmac: socfpga: Allow all RGMII modes Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 085/106] mac80211: fix channel switch trigger from unknown mesh peer Greg Kroah-Hartman
2020-05-01 13:23 ` [PATCH 5.6 086/106] sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 087/106] sched/vtime: Work around an unitialized variable warning Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 088/106] arm64: Delete the space separator in __emit_inst Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 089/106] ext4: use matching invalidatepage in ext4_writepage Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 090/106] ext4: increase wait time needed before reuse of deleted inode numbers Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 091/106] ext4: convert BUG_ONs to WARN_ONs in mballoc.c Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 092/106] irqchip/gic-v4.1: Add support for VPENDBASERs Dirty+Valid signaling Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 093/106] blk-mq: Put driver tag in blk_mq_dispatch_rq_list() when no budget Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 094/106] irqchip/meson-gpio: Fix HARDIRQ-safe -> HARDIRQ-unsafe lock order Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 095/106] hwmon: (jc42) Fix name to have no illegal characters Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 096/106] sfc: fix XDP-redirect in this driver Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 097/106] taprio: do not use BIT() in TCA_TAPRIO_ATTR_FLAG_* definitions Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 098/106] tipc: Add a missing case of TIPC_DIRECT_MSG type Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 099/106] qed: Fix race condition between scheduling and destroying the slowpath workqueue Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 100/106] Crypto: chelsio - Fixes a hang issue during driver registration Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 101/106] net: use indirect call wrappers for skb_copy_datagram_iter() Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 102/106] qed: Fix use after free in qed_chain_free Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 103/106] ext4: check for non-zero journal inum in ext4_calculate_overhead Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 104/106] ASoC: soc-pcm: fix regression in soc_new_pcm() Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 105/106] ASoC: soc-core: disable route checks for legacy devices Greg Kroah-Hartman
2020-05-01 13:24 ` [PATCH 5.6 106/106] ASoC: stm32: spdifrx: fix regmap status check Greg Kroah-Hartman
2020-05-01 15:17 ` [PATCH 5.6 000/106] 5.6.9-rc1 review Jon Hunter
2020-05-02 5:58 ` Greg Kroah-Hartman
2020-05-01 21:57 ` Naresh Kamboju
2020-05-01 22:18 ` Guenter Roeck
2020-05-02 6:17 ` Greg Kroah-Hartman
2020-05-02 7:15 ` Greg Kroah-Hartman
2020-05-02 23:14 ` shuah
2020-05-03 7:14 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200501131552.865351475@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).