Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2856746pxf; Sun, 21 Mar 2021 09:13:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqDUjdB4ebNJ+YPqD8zPt6KCJiR4SnXxl1RwbQeowHCFqbV+ghCLRZybFowk0rG1rk7qzS X-Received: by 2002:a05:6402:888:: with SMTP id e8mr20775985edy.51.1616343204779; Sun, 21 Mar 2021 09:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616343204; cv=none; d=google.com; s=arc-20160816; b=l4E/6QO/kRu95OUxtVVlOyXihZWk6JTfvxKO1EGEDkfX+l+onkxNyEjSbhuT53rRPV laNBAC4g3BHVRrj3tDx3nR+ipv1xr/0zW9spx7jil8eJkPoUUdZ5AFDbk5EqnfxO7Yy8 Xvr0MKh4i0+h1sQ89hS5NYcLB+cbbF3SZ5JQrMyk4CeJ9LviEzTMzoAxmUe6mkvg+EUZ pGnBaSfMbgtbZ9trArlA0efAWyFSy4EAiDrNMEYVypkFABm6eDKj1LxNqNs2nnqb1Dsa ECMUcMXZR3KSTZ5XNmhGrZC7k+5jMDeNb/OMZ6ZaR8wxHeuyIhzeml7tydAJB+OT2pXG Fstg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:subject:from:cc:to; bh=rC7GC7HXZloJ73D9BAkKdu0uVUYg5yYuEzxwtdlXRDo=; b=cCW4cWUNCb6uJnpcl1/KH4mbtnP4fw41+qVN0pquQU+Tac7hc+ndWuc3GQy53znh/1 4y0sFK4uSz2QxoVaOYOcJ2WfyDoylBqOxqfSBPhX71A4TyERD+O9K9C9YkNECX7Pd+AN /2mxnGvFUzYESJ/gxHjB/pQkAbLp6fMZRyvNYyjnetK66mLh3iJke3Xx84CzPlNp9KPZ xjnuHRA98ily5ZLGc4QZWG8x5HE9WmiD/z6KmrNhCvJUVY41GFSCeQi5xQgNOT/KnDLH ib3JTR3f9XTqonjpFbboXBB1D6sEuib80AZpzq/PnfxXA3bPAHX/d7aMje7y9Pvk6N0x qiiw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si9171306ejh.313.2021.03.21.09.13.02; Sun, 21 Mar 2021 09:13:24 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230264AbhCUPaK (ORCPT + 99 others); Sun, 21 Mar 2021 11:30:10 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:13998 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbhCUP3k (ORCPT ); Sun, 21 Mar 2021 11:29:40 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F3M2P1TmhzrZNw; Sun, 21 Mar 2021 23:27:41 +0800 (CST) Received: from [127.0.0.1] (10.174.176.117) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Sun, 21 Mar 2021 23:29:30 +0800 To: , , CC: , , , linfeilong , , "wubo (T)" From: Zhiqiang Liu Subject: [PATCH] pci: fix memory leak when virtio pci hotplug Message-ID: Date: Sun, 21 Mar 2021 23:29:30 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.117] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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