Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5549389ybl; Tue, 10 Dec 2019 07:48:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyYmrNcvYRQv1hGJuVBeWbR0Zj+XOrJojofPSKwpqpCohJ+59ubXvN6AJhiblvu/MYRwiz9 X-Received: by 2002:a05:6808:191:: with SMTP id w17mr4283150oic.29.1575992891577; Tue, 10 Dec 2019 07:48:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575992891; cv=none; d=google.com; s=arc-20160816; b=vC/ghThg5QcTs5NsBu3Yt6wPtfDzgBySK2SC4aWm8xaj2wBt4LmmAz9QbK7LduJWAP jWIXymlCfx3jRJTDEXh+33SUGVGofvqxCuPHvfK0ECdFbrnHntARyzBLNEdW60j3PjwL 3axuQBvI79F1tCTeQZwmRlRa5+VPMhyzhvumQzj/oZauE21ls6OzMo/utYBWOVPwItdQ KGWu4PedpnlPX4xIIE6CO7CYisx2zpDg4IeOuikaatoaD67aMOpItiqsbYmyfMp7w5Lh 715UomxHGK976gbAdNOdwUs/osPkRRCIrg1oiwnHPIew0tvGgEbxpRoHG3Us1ZIr/MdK K5BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=U60Nal8/Gl3ezIHTNYIZu0Xw+D+caRAan0hj/r6uk2Y=; b=Gw/uB4HhkuM1Mg+OlGKSG+W1mbez82RwAzzcEGAzr8YchlmJ4BmzrvEGoJgrEZTTqr KNTvAJklDyIKK7ySo4C/jMiYBC7CckXlm5ZMtvx59bOSDqqaXZAOYJtKSKEblcyNAaAC +8NpmSKbErM2OuI9abCW62Kbjgc37t7+oNYXDraXsjUBepy/PHSbv6XCfP9wyMW+Sko+ BjqQj3jKZR9QZXaXOyraJ7y1N0zHThGExEO+bkwJim480vcLnyDMOQyZWIvIPl3ug1rO foxTgSonrVvCbt5kTw8vVIc7o/jjnbP7xO5YkTGVzaiEXtE7XB/iLPndCRWbU/ps+nx0 GeVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g26si1936064otk.324.2019.12.10.07.47.59; Tue, 10 Dec 2019 07:48:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727603AbfLJPqw (ORCPT + 99 others); Tue, 10 Dec 2019 10:46:52 -0500 Received: from bmailout2.hostsharing.net ([83.223.78.240]:48669 "EHLO bmailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727178AbfLJPqw (ORCPT ); Tue, 10 Dec 2019 10:46:52 -0500 Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout2.hostsharing.net (Postfix) with ESMTPS id D29CC2801A03E; Tue, 10 Dec 2019 16:46:49 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 7B3DC973; Tue, 10 Dec 2019 16:46:49 +0100 (CET) Date: Tue, 10 Dec 2019 16:46:49 +0100 From: Lukas Wunner To: "Deucher, Alexander" Cc: Takashi Iwai , Jaroslav Kysela , Mika Westerberg , Bjorn Helgaas , Nicholas Johnson , "alsa-devel@alsa-project.org" , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" Subject: Re: [PATCH] ALSA: hda/hdmi - Fix duplicate unref of pci_dev Message-ID: <20191210154649.o3vsqzrtofhvcjrl@wunner.de> References: <77aa6c01aefe1ebc4004e87b0bc714f2759f15c4.1575985006.git.lukas@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 10, 2019 at 03:34:27PM +0000, Deucher, Alexander wrote: > > Nicholas Johnson reports a null pointer deref as well as a refcount underflow > > upon hot-removal of a Thunderbolt-attached AMD eGPU. > > He's bisected the issue down to commit 586bc4aab878 ("ALSA: hda/hdmi - fix > > vgaswitcheroo detection for AMD"). > > > > The commit iterates over PCI devices using pci_get_class() and unreferences > > each device found, even though pci_get_class() subsequently unreferences > > the device as well. Fix it. > > The pci_dev_put() a few lines above should probably be dropped as well. That one looks fine to me. The refcount is already increased in the caller get_bound_vga() via pci_get_domain_bus_and_slot() and it's increased again in atpx_present() via pci_get_class(). It needs to be decremented in atpx_present() to avoid leaking a ref. Thanks, Lukas > > diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index > > 35b4526f0d28..b856b89378ac 100644 > > --- a/sound/pci/hda/hda_intel.c > > +++ b/sound/pci/hda/hda_intel.c > > @@ -1419,7 +1419,6 @@ static bool atpx_present(void) > > return true; > > } > > } > > - pci_dev_put(pdev); > > } > > return false; > > } > > -- > > 2.24.0