From mboxrd@z Thu Jan 1 00:00:00 1970 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=-3.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 0B180C2BA19 for ; Thu, 23 Apr 2020 07:12:17 +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 88257208E4 for ; Thu, 23 Apr 2020 07:12:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="pb8DH7JD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 88257208E4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de 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 D5FD516DB; Thu, 23 Apr 2020 09:11:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D5FD516DB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1587625934; bh=YkjjGi+ZQtlS8uHxPka6cZ5175LAyRZHZBsCyOQY+hg=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=pb8DH7JDsRKxKDfGhHdgFGLwqUvTT6aQvPrjZ+GBUngl4+P/WALYYVFBr1SdJbfHs +vXbRnInzKTXkxYyCrhlBoOIWy4s/YpBTJNZ+gpcauNC1QPoV2O3aCP2ctWZqCPFpO Za9IUhjDpBfuh7UPU5P4+P8Rpb95THiu+viQOGms= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 61AF7F800F2; Thu, 23 Apr 2020 09:11:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 48AF7F801EC; Thu, 23 Apr 2020 09:11:19 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id ECC3EF800F2 for ; Thu, 23 Apr 2020 09:11:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz ECC3EF800F2 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7FC0EAE39; Thu, 23 Apr 2020 07:11:11 +0000 (UTC) Date: Thu, 23 Apr 2020 09:11:10 +0200 Message-ID: From: Takashi Iwai To: Xiyu Yang Subject: Re: [PATCH] ALSA: usb-audio: Fix usb audio refcnt leak when getting spdif In-Reply-To: <1587617711-13200-1-git-send-email-xiyuyang19@fudan.edu.cn> References: <1587617711-13200-1-git-send-email-xiyuyang19@fudan.edu.cn> 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 Cc: Pierre-Louis Bossart , Xin Tan , alsa-devel@alsa-project.org, Greg Kroah-Hartman , yuanxzhang@fudan.edu.cn, kjlu@umn.edu, Takashi Iwai , Colin Ian King , Thomas Gleixner , "Geoffrey D. Bennett" , linux-kernel@vger.kernel.org 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" On Thu, 23 Apr 2020 06:54:19 +0200, Xiyu Yang wrote: > > snd_microii_spdif_default_get() invokes snd_usb_lock_shutdown(), which > increases the refcount of the snd_usb_audio object "chip". > > When snd_microii_spdif_default_get() returns, local variable "chip" > becomes invalid, so the refcount should be decreased to keep refcount > balanced. > > The reference counting issue happens in several exception handling paths > of snd_microii_spdif_default_get(). When those error scenarios occur > such as usb_ifnum_to_if() returns NULL, the function forgets to decrease > the refcnt increased by snd_usb_lock_shutdown(), causing a refcnt leak. > > Fix this issue by jumping to "end" label when those error scenarios > occur. > > Signed-off-by: Xiyu Yang > Signed-off-by: Xin Tan Applied now (with Cc-to-stable and Fixes tags). thanks, Takashi