Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp830028pxb; Tue, 12 Apr 2022 14:39:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlqi2KsnnwgQUS31gmJben+5scO5wssnADNleJ551vaOWfk9W14mQpAFhbw8gqjyeVCheJ X-Received: by 2002:a17:902:b213:b0:156:5a00:325f with SMTP id t19-20020a170902b21300b001565a00325fmr39250366plr.127.1649799563659; Tue, 12 Apr 2022 14:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649799563; cv=none; d=google.com; s=arc-20160816; b=TC+eha2X4RD5F+mOBqBH9XPpbY7tSZ6SGs5j2+3RfOe2uxy2pCyIVzePzan7J7BXhJ 01PvitpStzw/ywGolHVMkPbjGMoqrfnWiEhU/ZED37u/a+s0pPNvxwpz04DwxKK38ySM dvIkYtYyCNx6qGBclvbbwyDs7AEiTLZ9JCUM30hHv4qy4liiVbOT4TY8H3++3tBgY/Bo 7wYnU6H4CkTs9SJp2+bAgiFNm+4eShdLbZiJaFMUpOEI8IkPMij0LcT4N0jxmPOJi1Yi V2LSzd/ExML3oTUbfIaxl3qdS+izPxAKOmz5DQVy0sn4jccxkisLVv8lmAzPVNhDe26z bx/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=Yh1GNW6gU42sVXZoPHtYENnDyIjgUm1nwQNJwCgjCEA=; b=CzOeJxhQR+obRezn7LmkJWz4ssq523TyILqlJK4Il3Pg3VYlld6+YqMWiXAHhzrnpl LLrR7WQLQJkIAQJkmlNlHbSQHe2StBAlTDE9R5wQbvtxceJgm59/cNSaIF62ptV6i08H rgkbRQHmA1etWzBD0Jf5GayXS94DC2Tb/EWOFlV0QsSO6xz3RmNJbwn1U6nE4aXEIbT7 eYXPsHMWZ4bLtpEa8K/sowbfFLmTavWClG4SMcOHwDe50hMfy7up0GWoEpp/2u5CsgjC Nv/zvZ5604jArNmhx/3954F3ljYNX4OlH3n5fN4MsUgXMmtNXqqexb93ylJSR6lnyNH8 oNvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=EqakTEAZ; dkim=neutral (no key) header.i=@suse.de; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j191-20020a638bc8000000b003816043f002si3622625pge.503.2022.04.12.14.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:39:23 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=EqakTEAZ; dkim=neutral (no key) header.i=@suse.de; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0D3B613365E; Tue, 12 Apr 2022 13:44:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344279AbiDKJSX (ORCPT + 99 others); Mon, 11 Apr 2022 05:18:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344381AbiDKJR4 (ORCPT ); Mon, 11 Apr 2022 05:17:56 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8257125E98 for ; Mon, 11 Apr 2022 02:15:42 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 2AB2B1F37D; Mon, 11 Apr 2022 09:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1649668541; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Yh1GNW6gU42sVXZoPHtYENnDyIjgUm1nwQNJwCgjCEA=; b=EqakTEAZ2mph5kkYg7YPFnK/6MbnQaNyEMO0t1MYwoCiHgeEWB1VzJm0dCR3lfI7AOjgTy Czlbe7F7Vonev3BSZ2kRTGB0raY0i/ifY0kGVokdGFSJvnMMXnFMiLQb2G7mcFFke1ixXI Murr6SvWAEEXL4jxkVZo2E706tkONbk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1649668541; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Yh1GNW6gU42sVXZoPHtYENnDyIjgUm1nwQNJwCgjCEA=; b=0RA8IxeJaW5gSq73ZxHKtdAmN9TxWTh1C5zAVhO/d8Lche3QpsdC7LKPh8U9vse27yiAXZ SAhmIHXljILWBwBA== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 21DBFA3B87; Mon, 11 Apr 2022 09:15:41 +0000 (UTC) Date: Mon, 11 Apr 2022 11:15:41 +0200 Message-ID: From: Takashi Iwai To: Zheyu Ma Cc: perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, Linux Kernel Mailing List Subject: Re: [BUG] ALSA: echoaudio: warning when the driver fails to probe In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 Apr 2022 11:06:09 +0200, Takashi Iwai wrote: > > On Mon, 11 Apr 2022 10:49:53 +0200, > Zheyu Ma wrote: > > > > On Mon, Apr 11, 2022 at 3:41 PM Takashi Iwai wrote: > > > > > > On Sun, 10 Apr 2022 11:13:55 +0200, > > > Zheyu Ma wrote: > > > > > > > > Hello, > > > > > > > > I found a bug in echoaudio.c. > > > > When the driver fails at the function snd_echo_create(), it should > > > > release resources requested before, otherwise we will get the > > > > following warning: > > > > > > > > [ 3.262866] remove_proc_entry: removing non-empty directory > > > > 'irq/21', leaking at least 'snd_indigodj' > > > > [ 3.263577] WARNING: CPU: 3 PID: 261 at fs/proc/generic.c:717 > > > > remove_proc_entry+0x389/0x3f0 > > > > [ 3.267098] RIP: 0010:remove_proc_entry+0x389/0x3f0 > > > > [ 3.269976] Call Trace: > > > > [ 3.269979] > > > > [ 3.269988] unregister_irq_proc+0x14c/0x170 > > > > [ 3.269997] irq_free_descs+0x94/0xe0 > > > > [ 3.270004] mp_unmap_irq+0xb6/0x100 > > > > [ 3.270011] acpi_unregister_gsi_ioapic+0x27/0x40 > > > > [ 3.270017] acpi_pci_irq_disable+0x1d3/0x320 > > > > [ 3.270025] pci_disable_device+0x1ad/0x380 > > > > [ 3.270034] pcim_release+0x566/0x6d0 > > > > [ 3.270046] devres_release_all+0x1f1/0x2c0 > > > > [ 3.270057] really_probe+0xe0/0x920 > > > > > > Could you try the patch below? > > > > The following patch works for me, the previous warning disappears, thank you. > > But I got another error, I have no idea about it. > > OK, that's bad, it's basically the destructor order problem. > Could you try the patch below instead of the previous one? Sorry, the below one instead. Takashi --- --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -1889,13 +1889,20 @@ static void snd_echo_free(struct snd_card *card) if (chip->comm_page) rest_in_peace(chip); - if (chip->irq >= 0) - free_irq(chip->irq, chip); - /* release chip data */ free_firmware_cache(chip); } +static void do_free_irq(void *p) +{ + struct echoaudio *chip = p; + + if (chip->irq >= 0) { + free_irq(chip->irq, chip); + chip->irq = -1; + } +} + /* <--snd_echo_probe() */ static int snd_echo_create(struct snd_card *card, struct pci_dev *pci) @@ -1936,6 +1943,9 @@ static int snd_echo_create(struct snd_card *card, return -ENOMEM; } + err = devm_add_action(card->dev, do_free_irq, chip); + if (err < 0) + return err; if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { dev_err(chip->card->dev, "cannot grab irq\n"); @@ -1946,8 +1956,6 @@ static int snd_echo_create(struct snd_card *card, dev_dbg(card->dev, "pci=%p irq=%d subdev=%04x Init hardware...\n", chip->pci, chip->irq, chip->pci->subsystem_device); - card->private_free = snd_echo_free; - /* Create the DSP comm page - this is the area of memory used for most of the communication with the DSP, which accesses it via bus mastering */ chip->commpage_dma_buf = @@ -1957,6 +1965,7 @@ static int snd_echo_create(struct snd_card *card, return -ENOMEM; chip->comm_page_phys = chip->commpage_dma_buf->addr; chip->comm_page = (struct comm_page *)chip->commpage_dma_buf->area; + card->private_free = snd_echo_free; err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device); if (err >= 0)