From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7666C433DB for ; Tue, 23 Mar 2021 18:25:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94926619C2 for ; Tue, 23 Mar 2021 18:25:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231493AbhCWSYz (ORCPT ); Tue, 23 Mar 2021 14:24:55 -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-pci@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 > >