Archive-only list for patches
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	"Cezary Rojewski" <cezary.rojewski@intel.com>,
	"Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 6.5 05/88] ASoC: core: Do not call link_exit() on uninitialized rtd objects
Date: Mon,  6 Nov 2023 14:02:59 +0100	[thread overview]
Message-ID: <20231106130305.963933242@linuxfoundation.org> (raw)
In-Reply-To: <20231106130305.772449722@linuxfoundation.org>

6.5-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>

[ Upstream commit dd9f9cc1e6b9391140afa5cf27bb47c9e2a08d02 ]

On init we have sequence:

	for_each_card_prelinks(card, i, dai_link) {
		ret = snd_soc_add_pcm_runtime(card, dai_link);

	ret = init_some_other_things(...);
	if (ret)
		goto probe_end:

	for_each_card_rtds(card, rtd) {
		ret = soc_init_pcm_runtime(card, rtd);

probe_end:

while on exit:
	for_each_card_rtds(card, rtd)
		snd_soc_link_exit(rtd);

If init_some_other_things() step fails due to error we end up with
not fully setup rtds and try to call snd_soc_link_exit on them, which
depending on contents on .link_exit handler, can end up dereferencing
NULL pointer.

Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20230929103243.705433-2-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/sound/soc.h  |  2 ++
 sound/soc/soc-core.c | 20 +++++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index b27f84580c5b0..cf34810882347 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1125,6 +1125,8 @@ struct snd_soc_pcm_runtime {
 	unsigned int pop_wait:1;
 	unsigned int fe_compr:1; /* for Dynamic PCM */
 
+	bool initialized;
+
 	int num_components;
 	struct snd_soc_component *components[]; /* CPU/Codec/Platform */
 };
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1a0bde23f5e6f..2d85164457f73 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1259,7 +1259,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
 	snd_soc_runtime_get_dai_fmt(rtd);
 	ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
 	if (ret)
-		return ret;
+		goto err;
 
 	/* add DPCM sysfs entries */
 	soc_dpcm_debugfs_add(rtd);
@@ -1284,17 +1284,26 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
 	/* create compress_device if possible */
 	ret = snd_soc_dai_compress_new(cpu_dai, rtd, num);
 	if (ret != -ENOTSUPP)
-		return ret;
+		goto err;
 
 	/* create the pcm */
 	ret = soc_new_pcm(rtd, num);
 	if (ret < 0) {
 		dev_err(card->dev, "ASoC: can't create pcm %s :%d\n",
 			dai_link->stream_name, ret);
-		return ret;
+		goto err;
 	}
 
-	return snd_soc_pcm_dai_new(rtd);
+	ret = snd_soc_pcm_dai_new(rtd);
+	if (ret < 0)
+		goto err;
+
+	rtd->initialized = true;
+
+	return 0;
+err:
+	snd_soc_link_exit(rtd);
+	return ret;
 }
 
 static void soc_set_name_prefix(struct snd_soc_card *card,
@@ -1892,7 +1901,8 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
 
 	/* release machine specific resources */
 	for_each_card_rtds(card, rtd)
-		snd_soc_link_exit(rtd);
+		if (rtd->initialized)
+			snd_soc_link_exit(rtd);
 	/* remove and free each DAI */
 	soc_remove_link_dais(card);
 	soc_remove_link_components(card);
-- 
2.42.0




  parent reply	other threads:[~2023-11-06 13:15 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-06 13:02 [PATCH 6.5 00/88] 6.5.11-rc1 review Greg Kroah-Hartman
2023-11-06 13:02 ` [PATCH 6.5 01/88] ASoC: Intel: sof_sdw: add support for SKU 0B14 Greg Kroah-Hartman
2023-11-06 13:02 ` [PATCH 6.5 02/88] ASoC: simple-card: fixup asoc_simple_probe() error handling Greg Kroah-Hartman
2023-11-06 13:02 ` [PATCH 6.5 03/88] coresight: tmc-etr: Disable warnings for allocation failures Greg Kroah-Hartman
2023-11-06 13:02 ` [PATCH 6.5 04/88] ASoC: fsl-asoc-card: use integer type for fll_id and pll_id Greg Kroah-Hartman
2023-11-06 13:02 ` Greg Kroah-Hartman [this message]
2023-11-06 13:03 ` [PATCH 6.5 06/88] ASoC: tlv320adc3xxx: BUG: Correct micbias setting Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 07/88] net: sched: cls_u32: Fix allocation size in u32_init() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 08/88] arm64: dts: imx93: add the Flex-CAN stop mode by GPR Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 09/88] can: flexcan: remove the auto stop mode for IMX93 Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 10/88] irqchip/riscv-intc: Mark all INTC nodes as initialized Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 11/88] irqchip/stm32-exti: add missing DT IRQ flag translation Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 12/88] dmaengine: ste_dma40: Fix PM disable depth imbalance in d40_probe Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 13/88] ata: pata_parport: add custom version of wait_after_reset Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 14/88] ata: pata_parport: fit3: implement IDE command set registers Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 15/88] powerpc/85xx: Fix math emulation exception Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 16/88] media: i2c: ov8858: Dont set fwnode in the driver Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 17/88] Input: synaptics-rmi4 - handle reset delay when using SMBus trsnsport Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 18/88] fbdev: atyfb: only use ioremap_uc() on i386 and ia64 Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 19/88] fs/ntfs3: Add ckeck in ni_update_parent() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 20/88] fs/ntfs3: Write immediately updated ntfs state Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 21/88] fs/ntfs3: Use kvmalloc instead of kmalloc(... __GFP_NOWARN) Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 22/88] fs/ntfs3: Add more attributes checks in mi_enum_attr() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 23/88] fs/ntfs3: Fix alternative boot searching Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 24/88] fs/ntfs3: Add more info into /proc/fs/ntfs3/<dev>/volinfo Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 25/88] fs/ntfs3: Do not allow to change label if volume is read-only Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 26/88] fs/ntfs3: Fix possible NULL-ptr-deref in ni_readpage_cmpr() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 27/88] fs/ntfs3: Fix NULL pointer dereference on error in attr_allocate_frame() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 28/88] fs/ntfs3: Fix directory element type detection Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 29/88] fs/ntfs3: Avoid possible memory leak Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 30/88] spi: npcm-fiu: Fix UMA reads when dummy.nbytes == 0 Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 31/88] ASoC: soc-dapm: Add helper for comparing widget name Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 32/88] netfilter: nfnetlink_log: silence bogus compiler warning Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 33/88] net/mlx5: Bridge, fix peer entry ageing in LAG mode Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 34/88] x86/efistub: Dont try to print after ExitBootService() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 35/88] efi: fix memory leak in krealloc failure handling Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 36/88] ASoC: rt5650: fix the wrong result of key button Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 37/88] ASoC: codecs: tas2780: Fix log of failed reset via I2C Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 38/88] s390/kasan: handle DCSS mapping in memory holes Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 39/88] drm/ttm: Reorder sys manager cleanup step Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 40/88] fbdev: omapfb: fix some error codes Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 41/88] fbdev: uvesafb: Call cn_del_callback() at the end of uvesafb_exit() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 42/88] scsi: mpt3sas: Fix in error path Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 43/88] ASoC: da7219: Correct the process of setting up Gnd switch in AAD Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 44/88] drm/amdgpu: Unset context priority is now invalid Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 45/88] gpu/drm: Eliminate DRM_SCHED_PRIORITY_UNSET Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 46/88] LoongArch: Use SYM_CODE_* to annotate exception handlers Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 47/88] LoongArch: Export symbol invalid_pud_table for modules building Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 48/88] LoongArch: Replace kmap_atomic() with kmap_local_page() in copy_user_highpage() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 49/88] LoongArch: Disable WUC for pgprot_writecombine() like ioremap_wc() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 50/88] netfilter: nf_tables: audit log object reset once per table Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 51/88] platform/mellanox: mlxbf-tmfifo: Fix a warning message Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 52/88] drm/amdgpu: Reserve fences for VM update Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 53/88] riscv: dts: thead: set dma-noncoherent to soc bus Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 54/88] net: chelsio: cxgb4: add an error code check in t4_load_phy_fw Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 55/88] r8152: Check for unplug in rtl_phy_patch_request() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 56/88] r8152: Check for unplug in r8153b_ups_en() / r8153c_ups_en() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 57/88] powerpc/mm: Fix boot crash with FLATMEM Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 58/88] io_uring: kiocb_done() should *not* trust ->ki_pos if ->{read,write}_iter() failed Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 59/88] ceph_wait_on_conflict_unlink(): grab reference before dropping ->d_lock Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 60/88] drm/amd/display: Dont use fsleep for PSR exit waits Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 61/88] rust: make `UnsafeCell` the outer type in `Opaque` Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 62/88] rust: types: make `Opaque` be `!Unpin` Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 63/88] power: supply: core: Use blocking_notifier_call_chain to avoid RCU complaint Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 64/88] perf evlist: Avoid frequency mode for the dummy event Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.5 65/88] mmap: fix vma_iterator in error path of vma_merge() Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 66/88] mmap: fix error paths with dup_anon_vma() Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 67/88] ALSA: usb-audio: add quirk flag to enable native DSD for McIntosh devices Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 68/88] PCI: Prevent xHCI driver from claiming AMD VanGogh USB3 DRD device Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 69/88] usb: storage: set 1.50 as the lower bcdDevice for older "Super Top" compatibility Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 70/88] usb: typec: tcpm: Add additional checks for contaminant Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 71/88] usb: typec: tcpm: Fix NULL pointer dereference in tcpm_pd_svdm() Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 72/88] usb: raw-gadget: properly handle interrupted requests Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 73/88] Bluetooth: hci_bcm4377: Mark bcm4378/bcm4387 as BROKEN_LE_CODED Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 74/88] tty: n_gsm: fix race condition in status line change on dead connections Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 75/88] tty: 8250: Remove UC-257 and UC-431 Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 76/88] tty: 8250: Add support for additional Brainboxes UC cards Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 77/88] tty: 8250: Add support for Brainboxes UP cards Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 78/88] tty: 8250: Add support for Intashield IS-100 Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 79/88] tty: 8250: Fix port count of PX-257 Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 80/88] tty: 8250: Fix up PX-803/PX-857 Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 81/88] tty: 8250: Add support for additional Brainboxes PX cards Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 82/88] tty: 8250: Add support for Intashield IX cards Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 83/88] tty: 8250: Add Brainboxes Oxford Semiconductor-based quirks Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 84/88] dt-bindings: serial: rs485: Add rs485-rts-active-high Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 85/88] misc: pci_endpoint_test: Add deviceID for J721S2 PCIe EP device support Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 86/88] serial: core: Fix runtime PM handling for pending tx Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 87/88] ALSA: hda: intel-dsp-config: Fix JSL Chromebook quirk detection Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 6.5 88/88] ASoC: SOF: sof-pci-dev: Fix community key " Greg Kroah-Hartman
2023-11-06 17:24 ` [PATCH 6.5 00/88] 6.5.11-rc1 review SeongJae Park
2023-11-06 18:09 ` Florian Fainelli
2023-11-07  3:07 ` Justin Forbes
2023-11-07  4:34 ` Bagas Sanjaya
2023-11-07  8:53 ` Ron Economos
2023-11-07 11:43 ` Jon Hunter
2023-11-07 15:28 ` Shuah Khan
2023-11-07 16:04 ` Conor Dooley
2023-11-07 17:12 ` Naresh Kamboju
2023-11-07 17:15 ` Ricardo B. Marliere
2023-11-07 18:54 ` Guenter Roeck

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=20231106130305.963933242@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /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