Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp105103pxf; Tue, 23 Mar 2021 23:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgdbh4cxuLOsOJux9aOm8K2wwMsU37uycVshNv8Zurwy9QTrpKH+Mkat4/aShreHsgqnxk X-Received: by 2002:a17:906:938f:: with SMTP id l15mr1994339ejx.15.1616568530504; Tue, 23 Mar 2021 23:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616568530; cv=none; d=google.com; s=arc-20160816; b=jNG4eag1R0A9cZyhW03NnQex+dJcdNwRRcg3LRHRT31XK9FHSzbMFCznmxBTNKD3iT j/udhTy+NwFCKHgHKX45MowexAw577lZFTxj+Qw4GV6kb/XBpff2pQ0ak1nta6XmJRKH pnXBkgRMmrUAMGSMx4PUqwwXpNbO0DsB4kiea4vamX/PrJzuafJ58dNbLndjM7u5iZgA yN3G+g76C+M8GN2GuvCdL1c1QRpEcC2A9+GXAON3WxY85dEWv9OBfgE6IxF5jec8XC8O 7kofXNiOk92zdium1xjZxVFm3BxgbjmALBhdI0RB/itdMKxbyl3kasOkcXK+hbDnS1QL ZR6Q== 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=fXx99mwG6eGOE8yKwx9/C6I+F07fOf01Vb+X5+sCUbY=; b=Dz7WGQ5ETxJ2pM9uC1CKRov6ZMGtTlysg+EB86pEUrNJy++xLAPPCZIo8J19LEZFYy uT4u5N2gL+T5tCGyQ6coDJtiV2CaGmmt+JQm3KAvNDdDxsWUxcEnm7+aQ7knuSLRzjIo KFmiLy8qOq8GuM9C35xkS5FNb6aSv9fNwwjDFqmnAr6430wgXFycaaUbbAoptmIaSvDL BfSYE2YMzIj7TBwK3TWU1bb79XQIqvLP/r+d+UlpB+W0xO4qeJO+2cLqCIzC1A82+kQC uMmRITmGwowzuub+f5EU9/B7whrJm2nwekZtTl2cqXOzjOFweFIxIxlVsa/lZEeoSf6/ Oubw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="KXV4pW/s"; 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 n6si1043546edq.597.2021.03.23.23.48.28; Tue, 23 Mar 2021 23:48:50 -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="KXV4pW/s"; 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 S231243AbhCWSY4 (ORCPT + 99 others); Tue, 23 Mar 2021 14:24:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:46804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231375AbhCWSYa (ORCPT ); Tue, 23 Mar 2021 14:24:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BC5EB619BF; Tue, 23 Mar 2021 18:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616523870; bh=2ByQMWPXsAbNM5t8yFCV5DKQH3QIgit6vLww0gdsRmg=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=KXV4pW/sFZRh+mjeGNctALrUSHm53TFGET9WN50ZdHPM6Ya2HaN1fxMgmP1+sx69V 8JXs2QhkPiaQ/0sCZlEYXOyEbowcGdXfaYu4dEnPIt5L+kSr9owflyL+I1nknLhp1/ 5mvZr9333DaUzmePYKLC2UPYH35eTHUHfiEuBvXpPPnCvK6iryWYzmchrmTZrOw8oV 4htg+RCw4wVm1sc/+UWvY5fYMVLZEh2zGa8Md8Ln6RvMRv0McdiJBm9cBxuk15mgGr lY/JyZ2U9KfzqTH5Uui640TDMXch0en9+ojK80QKTWiNHw7azk6llnT+MQl49+T40f SYqePFQRB+4mA== Date: Tue, 23 Mar 2021 13:24:28 -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 , "wubo (T)" Subject: Re: [PATCH] pci: fix memory leak when virtio pci hotplug Message-ID: <20210323182428.GA584698@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 Sun, Mar 21, 2021 at 11:29:30PM +0800, Zhiqiang Liu wrote: > From: Feilong Lin > > Repeated hot-plugging of pci devices for a virtual > machine driven by virtio, we found that there is a > leak in kmalloc-4k, which was confirmed as the memory > of the pci_device structure. Then we found out that > it was missing pci_dev_put() after pci_get_slot() in > enable_slot() of acpiphp_glue.c. > > Signed-off-by: Feilong Lin > Reviewed-by: Zhiqiang Liu Since this came from you, Zhiqiang, it needs a signed-off-by (not just a reviewed-by) from you. See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=v5.11#n361 Also see https://lore.kernel.org/r/20171026223701.GA25649@bhelgaas-glaptop.roam.corp.google.com and - Wrap commit log to fill 80 columns - s/pci/PCI/ (subject and commit log) - Run "git log --oneline drivers/pci/hotplug/acpiphp_glue.c". It's not completely consistent, but at least match the style of one of them. There is no "pci_device" structure. I think you mean the "struct pci_dev". The commit log doesn't actually say what the patch does. It's obvious from the patch, but it should say in the commit log. Look at previous commit logs to see how they do it. > --- > 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 > >