Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp556846pxf; Thu, 8 Apr 2021 08:27:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnwEGjQdiDZRhlvt2h4ywucU/9J+aZ1zXLdNwW23gC3px8C57t3tNd5BhSpRlHRcZ8m8mI X-Received: by 2002:a17:906:19d9:: with SMTP id h25mr11337782ejd.453.1617895658584; Thu, 08 Apr 2021 08:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617895658; cv=none; d=google.com; s=arc-20160816; b=sLf3N1sgfGIyLXq0DMKywlNP6MZC5KFfI5rpiwFXzSfsitFYFmOtEIi5vXYHgU3DPq 2JzWeT1lnJ6N32UPGLxGzVwaqNgGNVxsW8ksqoCFIcn5EocXwtwvKjwpVF2GTOCD2saq LMhqKV9X3q4JuNJ/t229FemFZ4rXaL5/xXitfmYhhPznNrasjnS0SKaCCVk1Hmt3X/q1 c50dUnZJe8tEyXKKm4vw7pJPJfMNSi0zeDkkBTkpNygxb/JhCnb6eI/SPkW75FKo7min wNlz2XKP7fy55pc1yCCxBuV5/lED3lbKDyMwjVqY56MSONYKowtcTYYw4+RvZCXSfrrv EYcg== 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=Jq7Qh7PEF0o+cWBQvV6HNXfJYjG7EeHZmm2kkOzV+Rs=; b=Qa9yP/4prrh1XE2xPiLL/3OCaUaWJSUHdADDVvd58xEYytvHKHh/1c9L/oMRpEI57i dFB/SoeJ56QeEYWPrqvxK2F8EEQXkPab4GY6xJnS9y9Po5HHJF5qwyrwpkI4wTY68V01 1ARjQigluFFz5D8yi1PGWVI0z1Bn9Z0KMmAPNiCaLKEK5v9uuaQY6e7MmDlEQ0moKN6T N42U6pRVJuzq1YGqykgTfLHOD7vYt9I1xO36UvRcb4WzxtuyT5Aa/imP5JKSBlk0z2hH HCcw8QqrLtVrzo0XHDzf2hDsspkxigBOtx+VXP12cAf2jW5eP6nexXFcizbUz0zJLyq0 yiMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eRDFNz9L; 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 z1si22786700edc.76.2021.04.08.08.27.15; Thu, 08 Apr 2021 08:27:38 -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=eRDFNz9L; 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 S231909AbhDHP0K (ORCPT + 99 others); Thu, 8 Apr 2021 11:26:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:47028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231791AbhDHP0I (ORCPT ); Thu, 8 Apr 2021 11:26:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 19BA861103; Thu, 8 Apr 2021 15:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617895557; bh=BsPq63IUE5jWhjlxvaXJnOCOfTCS2YyV8dn/2ZoA/lo=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=eRDFNz9LLPJlb7/BO6iRuz8b20it6l/spqCku3w8cbhaSpg/uE6wm3qFl2VgumX+J QGl8TcngavSZ94kjkK+MfyRPumJaImgi+zhrvAdWTUUIyNYstatpSWj9NYi58erxTZ 5v9E9NY7ZXetBWUcDuzu0Pnrz2le9TKBGNjXLCLfFGJ8NyCUyJrtLHCQCVH5j1D1j3 5M2euKQTUg5rF2AhXOefkgpw1/xl2QFW0A7nsSG/7cub4Z8UI5jjFr9vl2KCUP8AcA 8xLwFVczImw0H9sfcx/mqXDSRojENwVBX1wAc0ibb/LNz9Nc8fIuDRnqXI512nz71n 7LhpciDYlH++Q== Date: Thu, 8 Apr 2021 10:25:55 -0500 From: Bjorn Helgaas To: "Rafael J. Wysocki" Cc: Zhiqiang Liu , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , ACPI Devel Maling List , Linux PCI , "linux-kernel@vger.kernel.org" , linfeilong Subject: Re: [PATCH v2] ACPI / hotplug / PCI: fix memory leak in enable_slot() Message-ID: <20210408152555.GA1928260@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, Apr 08, 2021 at 05:18:46PM +0200, Rafael J. Wysocki wrote: > On Thu, Mar 25, 2021 at 8:27 AM 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 > > -- > > v2: rewrite subject and commit log as suggested by Bjorn Helgaas. > > The fix is correct AFAICS, so > > Reviewed-by: Rafael J. Wysocki > > Bjorn, has this been applied already? If not, do you want me to take > it or are you going to queue it up yourself? I'll pick it up; thanks for the review and the reminder! > > --- > > 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 > >