Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp608292pxf; Thu, 8 Apr 2021 09:21:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr0orh5Y553Dun8px9YkVPkPd6J20cNthyOOYz3pyMHeV9r3tqjzPjZIbRh7mTOyqqTx8/ X-Received: by 2002:a17:902:7203:b029:e6:a8b1:8d37 with SMTP id ba3-20020a1709027203b02900e6a8b18d37mr8538410plb.44.1617898914238; Thu, 08 Apr 2021 09:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617898914; cv=none; d=google.com; s=arc-20160816; b=L7lyqSnWZClFoATcfYf/ZLPyuyDimHW2UHgh6gB6wpD4CXMgY1KiLMn+oZjPuyA1od El/Xs+OwV1VTNOaz/xDCTfi+DZ27VRwsDiDc75X3SVCXKbQN7Qi6ZFh8xTHcs1uYbbTu UcCD/ccRtHuEw3OZWZqUZQ7RAMXcFbCVIl+SihWA03wLX2fp8Z/SXquptkK1Nh7kFelz aMRDWDaquxaTLYVcFFWXqlhaE3UOSQ0RK/8OSvFnj6t2bY8mv3Xoi0C77irVZ1sUcZn3 zcri9NFr02XEqTYw4SCiU2aoJpTP1FchnPZ6YHeKMHo7AFlYr38pqGx2UhEaUG4m5uYW QMiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=8+yDOXDubFrFEH0CP/AilaYL0og4T0ofXYNlwnS3MnI=; b=hyl7usa56quOEziaoa0xeQMLz8Im1fVeOBFEBHBk21MVBGGGgJ75RYzs9jijqh5ekB HjiBvRYwrT6tt11NybO8Sghxe5T1AULzgKzkUqFdcWn80TsSmC0YcdQl27HquqYG+tQY MYl4vG+ibrIMJbk8e8zO4G35s5SjWv3TaaDZoymk3UOJTkWI1cvLdaRV/IunpN2cU+7B AaIXbv8yc0rtUhLXJgzV389O4FaSt6R9UIc9CqU4i0cESMqIxDHni5v27luIO7oO4J34 MX3YPr9g8jMkloYLJdRM7ezdFEFYbHIJvOxZFfT6xcUPqY19tGKKdQoTtXqIp+NrFObX w5qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="C/SZY5er"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u6si18997345pga.266.2021.04.08.09.21.41; Thu, 08 Apr 2021 09:21:54 -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=@kernel.org header.s=k20201202 header.b="C/SZY5er"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232011AbhDHQUG (ORCPT + 99 others); Thu, 8 Apr 2021 12:20:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:58214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231655AbhDHQUE (ORCPT ); Thu, 8 Apr 2021 12:20:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 68C606100C; Thu, 8 Apr 2021 16:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617898792; bh=sQcy0UO9owIHSBc5AspToFAZP3AR67cYTVh7M3uYlHI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=C/SZY5ervrnUCW/cQ4uaCBHcxEEAQivAP2SNZaPCdbnvsiFZifMz8plLVA3O1M3pk GCTZ6hubYiNtNQml/8s+MZCnoJfe611w4ADmO/6jXMkHY8nJ7h+WbYxDOxPJmtQR2p PaHMLdKKejBeVEWhuKd35yK1QQZATUuxToJ069ZAmcHMhTLWs6Fr2X+k1zVUZdMVW0 GG/wMNOX5HQKg3+YvWbI4jTFdYNWbc+0DPoI3w9GeFbzGsCj+c4A0UdsCfoqML+S+q zIX49zQBY9CWeH9w9ebBBsMAh44R2k7dxde8OK7GoiFiE040+PKX4hxTzenAAGUZoy XP69yEpfHg33w== Date: Thu, 8 Apr 2021 11:19:51 -0500 From: Bjorn Helgaas To: Zhiqiang Liu Cc: rjw@rjwysocki.net, lenb@kernel.org, bhelgaas@google.com, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, "linux-kernel@vger.kernel.org" , linfeilong Subject: Re: [PATCH v2] ACPI / hotplug / PCI: fix memory leak in enable_slot() Message-ID: <20210408161951.GA1934960@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 25, 2021 at 03:26:00PM +0800, Zhiqiang Liu wrote: > From: Feilong Lin > > In enable_slot() in drivers/pci/hotplug/acpiphp_glue.c, if pci_get_slot() > will return NULL, we will do not set SLOT_ENABLED flag of slot. if one > device is found by calling pci_get_slot(), its reference count will be > increased. In this case, we did not call pci_dev_put() to decrement the > its reference count, the memory of the device (struct pci_dev type) will > leak. > > Fix it by calling pci_dev_put() to decrement its reference count after that > pci_get_slot() returns a PCI device. > > Signed-off-by: Feilong Lin > Signed-off-by: Zhiqiang Liu Applied with Rafael's reviewed-by to pci/hotplug for v5.13, thanks! > -- > v2: rewrite subject and commit log as suggested by Bjorn Helgaas. > --- > drivers/pci/hotplug/acpiphp_glue.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c > index 3365c93abf0e..f031302ad401 100644 > --- a/drivers/pci/hotplug/acpiphp_glue.c > +++ b/drivers/pci/hotplug/acpiphp_glue.c > @@ -533,6 +533,7 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge) > slot->flags &= ~SLOT_ENABLED; > continue; > } > + pci_dev_put(dev); > } > } > > -- > 2.19.1 >