Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp608340pxj; Thu, 20 May 2021 17:44:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdlVXik4IRVfrbbMR8e70EmHVk/XCp5RUCI3i+C/XhDiBXpim/8hG/PK40VEGREIl5CfnP X-Received: by 2002:a17:906:2ed0:: with SMTP id s16mr7303924eji.543.1621557851902; Thu, 20 May 2021 17:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621557851; cv=none; d=google.com; s=arc-20160816; b=At4npxmRlLr+ixWt769KQYlO5wBnpzLa3REFJT15maOLP8ayCwpgNMy0zODwNSXsZs H7UmGqvvEx8u5tEQPbErUE44bJuzgt5jee8Zq9vrCJ75LsNyW9H2HiyhKkA4/h8VyLvK 5ZZ45YjVHKk1M+CkUoSAljehqoYYOpcB6x6rcvMhXT1eKeQNyqQNlfOsOE001A2T9gdC GZ/6ILbSXXoBZA1UDrwAfmmKc/ha2j4HwwHfCLSXx7DmV9CAmL4NEDyOT2jXj32j80fn zdFC9YxUhjng7m6hS7X6f9c4ZuglBwXTU00BPIuW/S8t84aD2NEuAWhipNpytTdQkbVJ Jnsw== 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=flY/1Owq6T0pmFOtcQqzqwsxZYIoOvzZmn3uyDYrPmY=; b=DDfMyTIQMnz2fOO34DqwrP5+9jLTcm4nRo9MROrh/U63N858bS4q7WMV4yZSKjjFZR qp26hDkBg2jVfE1Im7W2cbrHH6Acsiimsrv6oaFV2hcKv3nhSvwxUfeBqHkgurRxgoHu Sdhs7uXhbJMZGFogaH5qDOY/lrKXk09zpBccaBINpx/MctBSHthCUaGP5BIc8W4rY+In wG3fFOLumjEhXX6aA9zhP4GZXvM/YbhLWdLFKDMJWltfgyRrxNokjItp2SMjc7GxNWlb 4bydJdEJ7g3AEdCHGDntpHt9BdH7xTRwwZKHM8zJwIfXaee70N5eshzJ34pfmPmmNYd9 G8vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cUVmjlWI; 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 n18si4119674eju.239.2021.05.20.17.43.48; Thu, 20 May 2021 17:44:11 -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=cUVmjlWI; 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 S241802AbhETLZa (ORCPT + 99 others); Thu, 20 May 2021 07:25:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:38974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239258AbhETLFr (ORCPT ); Thu, 20 May 2021 07:05:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D53C061D22; Thu, 20 May 2021 10:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505117; bh=LBUiWkUiNLs9ar18JzgmZtwMR793r1nSTlH0UvyhSQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cUVmjlWIvmyqqpyDWA66cVgDpRY+P/gjGZ+UyckayiVzlhcM8RJ8K/rTTU9pvDi/L Rdhhrvbt5PMmY3vU+dWdldVaOIaFAkJRYSYKdFtEge7EVfFr4jC4l0pUXDHeUJQ2aI piWX1j2diWUKsAUkVDNN04y4Wy0DB2s6if7JgPaE= 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.9 231/240] ACPI / hotplug / PCI: Fix reference count leak in enable_slot() Date: Thu, 20 May 2021 11:23:43 +0200 Message-Id: <20210520092116.457653477@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092108.587553970@linuxfoundation.org> References: <20210520092108.587553970@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 7f2b9ef185e4..f154b05f467f 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -538,6 +538,7 @@ static void enable_slot(struct acpiphp_slot *slot) slot->flags &= (~SLOT_ENABLED); continue; } + pci_dev_put(dev); } } -- 2.30.2