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: 11583851 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CD7413B6 for ; Tue, 2 Jun 2020 13:16:35 +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 E9F2D20835 for ; Tue, 2 Jun 2020 13:16:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="rlhD7P50" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9F2D20835 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 79EC61664; Tue, 2 Jun 2020 15:15:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 79EC61664 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591103793; bh=THVPnciWNL8ypd3jmXnRplLJiScM5XfBkjxr89+92Is=; h=To:Subject:From:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=rlhD7P50EDUOFagzydkDZLDa+cLnf7rSYFFg7ZDa8ROZBs3B1e9KLNB68tLuFOXzX 3BuHVIYv3e8n15tzNNo9VC4oTZ+bokqeoAZMLJUquKSoFVGCC6XViMyfh/5xrQ/ELW YQlgXg1T2xm9KXnHXUO7e3y0TfFBmB4kpk/PYMxs= 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) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6F014F8026F; Tue, 2 Jun 2020 11:48:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=MSGID_FROM_MTA_HEADER, PDS_BTC_ID,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 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_is?= =?utf-8?q?sue?= 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);