From patchwork Fri Sep 29 10:32:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 728126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BCBBE7F153 for ; Fri, 29 Sep 2023 10:40:31 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D3946DEB; Fri, 29 Sep 2023 12:39:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D3946DEB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1695984029; bh=H74qFM+oOOUHPmlwGKYaOXRgArSJXWBY6J00GbX4p3s=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=FXAWk1aqGVLZEpjVN5wSlmEyld4srlDMDl0JeVM0f53Iz5pO+ynBpGuhfNEpR4404 jepEOlIsS+9cnEqZXQjAR3qucOgoys29vmlYxX8MrHVQkEClo6ro/N7U0MK1ATP8/d rmpO1qmFVzW17bjVIi5JBRCggt61HdA3vK7ADNzA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 581D8F8016A; Fri, 29 Sep 2023 12:39:18 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id E1BCDF8007C; Fri, 29 Sep 2023 12:39:17 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 20D76F801D5; Fri, 29 Sep 2023 12:36:48 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 43CA8F8007C for ; Fri, 29 Sep 2023 12:33:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 43CA8F8007C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=h13fj35N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695983597; x=1727519597; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=H74qFM+oOOUHPmlwGKYaOXRgArSJXWBY6J00GbX4p3s=; b=h13fj35NcpKXY6LCgVnIqUztChUZ72avQI/mz6MeVquYruRE+9HOIjEb +zhii7FkowEOLob0HAj6sl8m0coOVDjhgicsxK9GOo837aWzE/6sOuYn6 cfDUX7555UUuitbNM1WJ1WPyvcpUKSe6TiWJsAFgJTJoCbRItqIcaU86Z 5riiXqch3B97ZhbVJp71nXBmR76pb5nI1bMvaJmRu/bKET4ETaQ7Az4nz 5phNQyX2tGeLCIx2SgRo1omPU75aCQ5oip7R6JEt/Mna9QzG/N+WmAv1I uKG8lAwY0T/q5AUbm49ud79qbBudHgfl7OhPahzaEvJL9hnayKDHNfwpp w==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="386135658" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="386135658" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 03:32:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="699604548" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="699604548" Received: from dev2 (HELO DEV2.igk.intel.com) ([10.237.148.94]) by orsmga003.jf.intel.com with ESMTP; 29 Sep 2023 03:32:34 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Takashi Iwai , Jaroslav Kysela , alsa-devel@alsa-project.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 1/2] ASoC: core: Print component name when printing log Date: Fri, 29 Sep 2023 12:32:42 +0200 Message-Id: <20230929103243.705433-1-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Message-ID-Hash: 6QM4QPZKBHYBHMG4DJRKDJNO5EEJMPL5 X-Message-ID-Hash: 6QM4QPZKBHYBHMG4DJRKDJNO5EEJMPL5 X-MailFrom: amadeuszx.slawinski@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: When printing log related to component it is useful to know, to which component it applies to. Reviewed-by: Cezary Rojewski Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c305e94762c3..2b8d522eb106 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1445,8 +1445,8 @@ static int soc_probe_component(struct snd_soc_card *card, if (component->card) { if (component->card != card) { dev_err(component->dev, - "Trying to bind component to card \"%s\" but is already bound to card \"%s\"\n", - card->name, component->card->name); + "Trying to bind component \"%s\" to card \"%s\" but is already bound to card \"%s\"\n", + component->name, card->name, component->card->name); return -ENODEV; } return 0; From patchwork Fri Sep 29 10:32:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 727639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6461EE732D0 for ; Fri, 29 Sep 2023 10:34:42 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 661CAAEA; Fri, 29 Sep 2023 12:33:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 661CAAEA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1695983679; bh=YZTezP7IUTtyzH0ZtF3o1amsIocAeu8ha/k7HI/hkec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=X+OG/fv6UBkViBfQhMhwsXD5Lzz8ETNXL2WdOJl86M6zpUzfDYkaKVn6dtSmKQRz6 iLyLer5qawC7P43+DVIezVyfnJrmichCW1K/FYlUqWzYVzlWBrJVKxrs5MHWkVOc8c GCQGEus3yPds3VZyLK699pyJ+eYg9QIpBm/n0bRg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 19BABF8055A; Fri, 29 Sep 2023 12:33:29 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id BCE37F80290; Fri, 29 Sep 2023 12:33:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 27A36F80290; Fri, 29 Sep 2023 12:33:21 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 469C5F800AE for ; Fri, 29 Sep 2023 12:32:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 469C5F800AE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=dxoEMgAu DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695983595; x=1727519595; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YZTezP7IUTtyzH0ZtF3o1amsIocAeu8ha/k7HI/hkec=; b=dxoEMgAuQ0XtFx7YN0g16VrSAnQi6TY7gG4RQIdZ9/MSNziHvUDrXw7T ewZDfX8Kll+STgeTRKJ9+n9jSHRNhhqK9Xu0vU2AXKMRU75xMP/MnzltQ TN3HPafkRyxnSsOfmV3XYlIxNI/w7TtmTcCMNjWPD3hBeEi4+rXAg47Tp BwP6JJ6aS94PtJ3d7cvmt3rk6hZKW5Fg9pL5OF/2A4bckUQOEsphKY7t2 KAtdndO7Xzb3BZ01Xsgkhz6rIIfgtF2m6ts0NUwbYR21ZRbiuOPD/iV17 rTbDpd32wQLP/iRwRuUzcHP5GtrpmInJxUO3ubv5GTrlHZ2NMtTYvl6YR A==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="386135663" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="386135663" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 03:32:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="699604564" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="699604564" Received: from dev2 (HELO DEV2.igk.intel.com) ([10.237.148.94]) by orsmga003.jf.intel.com with ESMTP; 29 Sep 2023 03:32:35 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Takashi Iwai , Jaroslav Kysela , alsa-devel@alsa-project.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 2/2] ASoC: core: Do not call link_exit() on uninitialized rtd objects Date: Fri, 29 Sep 2023 12:32:43 +0200 Message-Id: <20230929103243.705433-2-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929103243.705433-1-amadeuszx.slawinski@linux.intel.com> References: <20230929103243.705433-1-amadeuszx.slawinski@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: RELT54GEX5OB3PYOKYB23IFKCURUWUZC X-Message-ID-Hash: RELT54GEX5OB3PYOKYB23IFKCURUWUZC X-MailFrom: amadeuszx.slawinski@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 Signed-off-by: Amadeusz Sławiński --- 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 63b57f58cc56..7792c393e238 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1134,6 +1134,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 2b8d522eb106..b2bd45e87bc3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1347,7 +1347,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); @@ -1372,17 +1372,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, @@ -1980,7 +1989,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);