Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp490900pxj; Thu, 20 May 2021 14:18:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9lkA7RQyl2s4Kgpan/LnN4L5CPy0NBAF8SaUUXVejHTXHrrqCcExBE+++fHf5n+73cl6A X-Received: by 2002:a50:bec1:: with SMTP id e1mr7094877edk.116.1621545490397; Thu, 20 May 2021 14:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621545490; cv=none; d=google.com; s=arc-20160816; b=Iw46bgrWMX6YQ8+gFc2WalgJnOhbFvPXBTZ+vdvh+Zr7OJUQsYd7bbiAipHIEe5hzy jh+vOarweyepynF797OcKgnsya6MAnskqwjkpElrN4yKyyoJ3Rpvvpk4jb2mjgrCPsRP dCbd4pLtPyK0KUvr2Y7LIZXEIV3jxEIwS72DWpnyjiasjCDLDMo4JLcEE5Upz/uPTnoe OEU7RdkhHo/fvobKYyX+tUU7zlFCn0Xk+WGOohM/14hYR4VFB/YJD8mtbuhQPFexi5iA rDy+/xk0v1hhwk39VnriXdsfiB+FQ3kXXvMx2vK79OKQrXLokQkXf7GyWNYwNWzfA6VA o/eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vEAf3Hy4BxbPgTU5DU97PEE7ZGehRtW607QgIkyleaU=; b=cYc3mdXkMXwcTHsbMmI3pSiKj7sSyCS4cvOwwvV4D/rOoBF4IhslqAPuRziZ9pdMOB EknN0TFb2H8m8lKMbayNITQVHaO2WN7+ommWCgZH8Eym4c/pMPrutfVLf4MqYNOcMfiC CxWCzrncUMrWfiD7vfW0YV9JSS+YkjOjgeTBscG8/Ma9TiWx5fBNTBuNPGB51DSMBAHP urTUwaitnFkX8ZyPA7wA8CNOmmv6LfehDt5WJfrLN1fZ5nH1blMGfLTtBDSEVb1gXVXv dXZMRPoTQ9i8OA2LHtTSLPuWISi4c5ZOr4Ls/gDOtthaPNz0ITUUZC1VnA2GEo6LoydX Sp6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uiwv9Sct; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f25si3458753eja.351.2021.05.20.14.17.45; Thu, 20 May 2021 14:18:10 -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=@linuxfoundation.org header.s=korg header.b=uiwv9Sct; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238946AbhETLBj (ORCPT + 99 others); Thu, 20 May 2021 07:01:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:43868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237227AbhETKmn (ORCPT ); Thu, 20 May 2021 06:42:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 61BF861C93; Thu, 20 May 2021 09:56:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504582; bh=84ey2UjrGv61T0itePr91cHQ3aTRkpF+WMV1VJ404U4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uiwv9SctZh2jHZj9uqjIE8VVObmOf4+R8+1h4wpmrrREAmRD7dGc2mQOtVd3sQ8mp niSSN4C9ZNvw8lmRiEncFrkSZz1oRkiH+qD3JhsBWCGOKVhC4YRj1b8suMl69r4uDj 4AW2IRKkiUW+gN2D1+22lL388fGNX5SYDqADLEK4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Feilong Lin , Zhiqiang Liu , Bjorn Helgaas , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.14 310/323] ACPI / hotplug / PCI: Fix reference count leak in enable_slot() Date: Thu, 20 May 2021 11:23:22 +0200 Message-Id: <20210520092130.857967546@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Feilong Lin [ Upstream commit 3bbfd319034ddce59e023837a4aa11439460509b ] In enable_slot(), if pci_get_slot() returns NULL, we clear the SLOT_ENABLED flag. When pci_get_slot() finds a device, it increments the device's reference count. In this case, we did not call pci_dev_put() to decrement the reference count, so the memory of the device (struct pci_dev type) will eventually leak. Call pci_dev_put() to decrement its reference count when pci_get_slot() returns a PCI device. Link: https://lore.kernel.org/r/b411af88-5049-a1c6-83ac-d104a1f429be@huawei.com Signed-off-by: Feilong Lin Signed-off-by: Zhiqiang Liu Signed-off-by: Bjorn Helgaas Reviewed-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- 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 f2c1008e0f76..40e936e3a480 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -509,6 +509,7 @@ static void enable_slot(struct acpiphp_slot *slot) slot->flags &= (~SLOT_ENABLED); continue; } + pci_dev_put(dev); } } -- 2.30.2