Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3525906pxf; Mon, 15 Mar 2021 11:30:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnjeOyzsic96m7wJNTbpFAY/RxiK585+NdXpc7QBNUhxmKeT52cwD1eRwKKk8+zgaocA1o X-Received: by 2002:a17:906:9888:: with SMTP id zc8mr25660973ejb.310.1615833040051; Mon, 15 Mar 2021 11:30:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833040; cv=none; d=google.com; s=arc-20160816; b=1Ee5kA6dH9Z4YbO71IjnyuQHTzP9K/1wINjaNIySeplhdpLSSbTkQ+uWuw66oDQyqq K0KMaPDgNpOxqO8IcIiBiw0lYI/Ad1NCaYAYbrYbCNIdoVN3uH1U3aQukf5qxLduTWAE fhbWsfeMEZiw7GHxlZ92Ob2zT3vSqGDuZcFgOMp0wGfOt/CdfxA547ZveGJbDEhuH4hw znFstixtSQ435+RM1aHf5HhFMTHD+haSlLCdVpusrIPx2LOBQBoNbnA9L6B0nWudiUHL JOX37BFhCiBa/t7CiJUHCiMmSjXqDtOVdYO5w5sUuMeNk0K6kUa+nl2Dgmz/eLIIWoii nqqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NW7yUPht1sIEZLDMF0k0GAPiVkvyVH0iGe5E5l+U+aM=; b=M8/poO/k50rY9Q8RHmaAdEZzvdurcGOrwhueM1fI8UJhV8mtohOoqHhMHhTCXkrw5a 8C3I7hWlWYBkPDCIvDxP8J9npNiGLbLcVA5cYBuSSpxdWrxUQ39ucao4GkIvpJr+nEvu ojqkwremObzBSfV6axke1/kl+BvcLh+b8GF1S8pLCDuXgH6afG/rsiuSOCcJv6s2JV1j OwMbeQ7kl3wBo4q6ba6V8GgEkPLlkngCpSLXhFMC82eAMJvUatQyEkukPma41/XWkXf4 kGCiSQnfhLMGREghQjdFLhj3DOtdxuyN7qdRxFBqjRL6lc+RneDwkoU3p2U8SuTsIlKU LCZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lb98dc3c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e12si11744209ejs.501.2021.03.15.11.30.17; Mon, 15 Mar 2021 11:30:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lb98dc3c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238629AbhCOOhO (ORCPT + 99 others); Mon, 15 Mar 2021 10:37:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:47794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233190AbhCOOBs (ORCPT ); Mon, 15 Mar 2021 10:01:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E025C64EEE; Mon, 15 Mar 2021 14:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816908; bh=2X/boaDRY/ALEiqf8bsk4O1+AVCwb495o8No2lJS2Qs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lb98dc3cexsXHEAO30fjG7op9LKw2dH4bdmZQUCt3SKYxmBs4DDBvUx4MeVSSs4ke TJwnAzJVP2YZEXJ1/NV5ZNk2SPJrOlDEMEDiEHpgkH9lEcCNLS0TbqnB5zxIGJCwBl xKl6boYeruGLTLPJL3E6LMSF1y8ZuK5vFCad2Es0= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , Takashi Iwai Subject: [PATCH 5.10 182/290] ALSA: usb-audio: fix use after free in usb_audio_disconnect Date: Mon, 15 Mar 2021 14:54:35 +0100 Message-Id: <20210315135548.067241273@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Pavel Skripkin commit c5aa956eaeb05fe87e33433d7fd9f5e4d23c7416 upstream. The problem was in wrong "if" placement. chip->quirk_type is freed in snd_card_free_when_closed(), but inside if statement it's accesed. Fixes: 9799110825db ("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()") Signed-off-by: Pavel Skripkin Cc: Link: https://lore.kernel.org/r/16da19126ff461e5e64a9aec648cce28fb8ed73e.1615242183.git.paskripkin@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/card.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -907,6 +907,9 @@ static void usb_audio_disconnect(struct } } + if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND) + usb_enable_autosuspend(interface_to_usbdev(intf)); + chip->num_interfaces--; if (chip->num_interfaces <= 0) { usb_chip[chip->index] = NULL; @@ -915,9 +918,6 @@ static void usb_audio_disconnect(struct } else { mutex_unlock(®ister_mutex); } - - if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND) - usb_enable_autosuspend(interface_to_usbdev(intf)); } /* lock the shutdown (disconnect) task and autoresume */