From patchwork Tue Jun 2 09:48:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5pyx54G/54G/?= X-Patchwork-Id: 192523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, PDS_BTC_ID, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AA25C433DF for ; Tue, 2 Jun 2020 13:16:36 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0FA102074B for ; Tue, 2 Jun 2020 13:16:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="X0kXaW/2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0FA102074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 897F0168A; Tue, 2 Jun 2020 15:15:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 897F0168A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591103794; bh=THVPnciWNL8ypd3jmXnRplLJiScM5XfBkjxr89+92Is=; h=To:Subject:From:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=X0kXaW/2/jicyZKqdPTUhgL5zDUay4j7f3yQ9cmxxqMT/SheE/R4g3yYWh2PxnXuC D94HVzpZqgisrvDmBXzo53aJ7vNx442Ia7SpFm/Gz5XFmLIUSV6pcrmCNA4Vra9OI2 sphQwOn4sBIPpDec5lIQ84QnhDWpznma//r674NE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 31BFCF802DF; Tue, 2 Jun 2020 15:10:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6F014F8026F; Tue, 2 Jun 2020 11:48:18 +0200 (CEST) Received: from m176150.mail.qiye.163.com (m176150.mail.qiye.163.com [59.111.176.150]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4FB31F800BC for ; Tue, 2 Jun 2020 11:48:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4FB31F800BC Received: from vivo.com (wm-10.qy.internal [127.0.0.1]) by m176150.mail.qiye.163.com (Hmail) with ESMTP id B33C11A31FD; Tue, 2 Jun 2020 17:48:04 +0800 (CST) Message-ID: To: tiwai@suse.com, perex@perex.cz, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: =?utf-8?q?=5BPATCH=5D_ALSA=3A_core=3A_Fix_control_device_release?= =?utf-8?q?_issue?= X-Priority: 3 X-Mailer: HMail Webmail Server V2.0 Copyright (c) 2016-163.com X-Originating-IP: 58.251.74.227 MIME-Version: 1.0 Received: from zhucancan@vivo.com( [58.251.74.227) ] by ajax-webmail ( [127.0.0.1] ) ; Tue, 2 Jun 2020 17:48:04 +0800 (GMT+08:00) From: =?utf-8?b?5pyx54G/54G/?= Date: Tue, 2 Jun 2020 17:48:04 +0800 (GMT+08:00) X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZTlVKSU1CQkJDTk5LT0pOWVdZKFlBSE 83V1ktWUFJV1kPCRoVCBIfWUFZLRYpTzgcPxU1Ok4uMjUhHk4XMks6OlZWVUhLTyhJWVdZCQ4XHg hZQVk1NCk2OjckKS43PllXWRYaDxIVHRRZQVk0MFkG X-HM-Sender-Digest: e1kMHhlZQQ8JDh5XWRIfHhUPWUFZRzo3STo2DD8MODpOHjw#NEhPSioY EBoJClVKVUpOQkpLQkpJQ09DSE9VMxYaEhdVARMOGBoVGBoVOw0SDRRVGBQWRVlXWRILWUFZTkNV SU5KVUxPVUlJTFlXWQgBWUFMSE5PNwY+ X-HM-Tid: 0a72746e4b0d93b4kuwsb33c11a31fd X-Mailman-Approved-At: Tue, 02 Jun 2020 15:10:44 +0200 Cc: kernel , wenhu wang , cancan zhu X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: zhucancan Date: Tue, 2 Jun 2020 16:22:57 +0800 Subject: [PATCH] ALSA: core: Fix control device release issue We use snd_pcm_add_usr_ctls() in component's .pcm_new(), unfortunately snd_soc_dapm_add_routes() meets error during adding card->dapm_routes/of_dapm_routes, it will goto probe_end to call soc_cleanup_card_resources(). The commit dc82e52492f6 ("ALSA: core: Assure control device to be registered at last") will make pcm device release is prior to control device release, but the control device needs to use pcm pointor, which is already freed by pcm device release. [ 70.056000] Unable to handle kernel paging request at virtual address ffffff80f2d2c480 [ 70.066139] init: processing action (init.svc.media=*) from (/system/etc/init/mediaserver.rc:1) [ 70.076311] Mem abort info: [ 70.126679] ESR = 0x96000047 [ 70.126685] EC = 0x25: DABT (current EL), IL = 32 bits [ 70.126689] SET = 0, FnV = 0 [ 70.126693] EA = 0, S1PTW = 0 [ 70.126696] Data abort info: [ 70.126700] ISV = 0, ISS = 0x00000047 [ 70.126704] CM = 0, WnR = 1 [ 70.126710] swapper pgtable: 4k pages, 39-bit VAs, pgdp=00000000a216b000 [ 70.126715] [ffffff80f2d2c480] pgd=00000001ffb7f003, pud=00000001ffb7f003, pmd=00000001ff9e8003, pte=0068000172d2cf12 [ 70.126731] Internal error: Oops: 96000047 [#1] PREEMPT SMP [ 70.126821] CPU: 0 PID: 5 Comm: kworker/0:0 Tainted: G W O 5.4.12-qgki-debug-g4c7ca9f20 #10 [ 70.126840] Workqueue: events deferred_probe_work_func$2b500e852cead69fde05a2b98ceb2fa6.cfi_jt [ 70.126845] pstate: 80c00005 (Nzcv daif +PAN +UAO) [ 70.126854] pc : pcm_usr_ctl_private_free$165f4400ee6732c7c8c8157be0f72518+0x20/0x34 [ 70.126861] lr : snd_ctl_remove+0xf4/0x154 [ 70.126862] sp : ffffffc01007b750 [ 70.126865] x29: ffffffc01007b750 x28: ffffffd973c2bb2c [ 70.126868] x27: ffffff8107b741a0 x26: dead000000000100 [ 70.126874] x25: 0000000000000002 x24: ffffffd973c2bb8c [ 70.126877] x23: ffffffd975027c80 x22: ffffffd97415437f [ 70.126880] x21: 0000000000000001 x20: ffffffd973c37e10 [ 70.126883] x19: ffffff80f2d55d00 x18: ffffff80451de4d0 [ 70.126886] x17: ffffff80f2d58000 x16: 0000000000000400 [ 70.126889] x15: a6fe4e9bdc5a6b05 x14: 0000000000000000 [ 70.126892] x13: ffffffff03ab5408 x12: 0000000000000001 [ 70.126896] x11: 7079542070704120 x10: 0000000000000398 [ 70.126899] x9 : 0000000000000001 x8 : ffffff80f2d2c398 [ 70.126902] x7 : 0000000000000000 x6 : ffffff80f6b4d178 [ 70.126905] x5 : ffffffd97335fe8c x4 : 0000000000000000 [ 70.126908] x3 : ffffffc01007b650 x2 : ffffffc01007b768 [ 70.126911] x1 : 00000000ffffffff x0 : ffffff811ff41480 [ 70.126916] Call trace: [ 70.126920] pcm_usr_ctl_private_free$165f4400ee6732c7c8c8157be0f72518+0x20/0x34 [ 70.126923] snd_ctl_remove+0xf4/0x154 [ 70.126927] snd_ctl_dev_free$1b8efea49186b79e6e4a39cac5748f1c+0x3c/0x70 [ 70.126930] snd_device_free_all+0x234/0x2c8 [ 70.126934] release_card_device$fb7328386cac0bdf1b3f2f88da79521f+0x24/0xcc [ 70.126941] device_release$d2fdd8912beb71f9ccc7ca72fceb0522+0x48/0x118 [ 70.126949] kobject_cleanup+0x138/0x25c [ 70.126952] kobject_put+0x50/0x60 [ 70.126955] put_device+0x14/0x20 [ 70.126957] snd_card_free+0x60/0x98 [ 70.126963] soc_cleanup_card_resources+0x2c/0x420 [ 70.126966] snd_soc_bind_card+0xcc0/0xfa8 [ 70.126968] snd_soc_register_card+0x110/0x128 [ 70.126974] devm_snd_soc_register_card+0x4c/0x90 Fixes: dc82e52492f6 ("ALSA: core: Assure control device to be registered at last") Signed-off-by: zhucancan --- sound/core/device.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sound/core/device.c b/sound/core/device.c index bf0b04a7ee79..1aee0f5623a2 100644 --- a/sound/core/device.c +++ b/sound/core/device.c @@ -225,14 +225,6 @@ void snd_device_free_all(struct snd_card *card) if (snd_BUG_ON(!card)) return; - list_for_each_entry_safe_reverse(dev, next, &card->devices, list) { - /* exception: free ctl and lowlevel stuff later */ - if (dev->type == SNDRV_DEV_CONTROL || - dev->type == SNDRV_DEV_LOWLEVEL) - continue; - __snd_device_free(dev); - } - /* free all */ list_for_each_entry_safe_reverse(dev, next, &card->devices, list) __snd_device_free(dev);