Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp640227pxj; Thu, 20 May 2021 18:42:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQEBtFC7iKng32JVINszzKlK9HKsa2QAdlO5E0ncxBjcGoKwd65QYqx9n8pXIoL9zUrOx6 X-Received: by 2002:a17:906:b0d:: with SMTP id u13mr7257345ejg.159.1621561320547; Thu, 20 May 2021 18:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621561320; cv=none; d=google.com; s=arc-20160816; b=ODIZ2HIaBWAmt6PtF2AqFxHiGRBa0m1cDutkWvGfbjXdPJ6DHxPeiE+il7OZQySS3h GKeFBTxK4KzIZ3YjUBwi5WjyoTakxUD34d32QRXFWV2Z3FrytaZjoHHOHrxMb/btzvxA xGDxHoZ7rixKTRyQ+7yTrdyMivTuGU5cGYucHEiYF7+LHpUqGFSuwTr1G+OTfgg/ZZxP Pd7YFl3kVzYViKn46DcNpOjs867rWfFTgg3u2bhXIyBhm26jBX0KSOFPWtEO58nr1X8v SAQq5aI13aKOnWn0ANm2o9S7xqKcZkKVyqTgdSYEg8Uq4+1ih+05FI3/dXMeZSzLCkf5 teHg== 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=14UBLxvscuQpV2XuYKShzJj3ijRHUIwt/zpa1K+/2qU=; b=HmCvolVXjc9hD7zAmccKIOrJlitHRmqZvXZLqITbukCcgO3DvgFN2xHt7vGAsCipNh bWBZ7sWuGUwlpFMj/Alw9h3ZG1wh371GiCFWk6bPElu8Vxb8lrLUL1/C/qQDDvxeg9lu vdXmD3vQ8GPTVs5tv67IkyPje6hDRfemu0BEsfm6hnQkGzQMXTEihxLSbsOtwmt28Q5N L+MN7SE/MCeGuk5SN+GSXpVwp4FfLBkvJ14et61P9Igw/MB61MjU/am1I1KTeaDe/i5E akJhXCsgQ2KQbLlrnXrhaBjK1BKB5uUrOiEguZLXxdfL60BgILdrL6UEb4Z6ZKqkGyLy pTUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PrI3QY4U; 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 o21si3690757ejg.525.2021.05.20.18.41.37; Thu, 20 May 2021 18:42:00 -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=PrI3QY4U; 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 S242828AbhETLru (ORCPT + 99 others); Thu, 20 May 2021 07:47:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:45560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241675AbhETLZT (ORCPT ); Thu, 20 May 2021 07:25:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 068A561DA4; Thu, 20 May 2021 10:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505577; bh=GHNW1VEkKb55FmHjQlxYLF5p1T+n36T/oqo5B8UjFYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PrI3QY4U2OkijQxU2azc5s4jlLFWEyBhQr+YZUgjqf4RRAnOcY4Ot6mfXw/+jOS1k zUpXaZ0O9QTnctrqD8oVOLRybjS0c8b4UvU8GNK5M+TzBhGaqxCmp7hsWVF+EuyWIY FgbIZ9FUZXjsxvZ9FLMP8loPkBQCxdbJazq5RfEA= 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.4 183/190] ACPI / hotplug / PCI: Fix reference count leak in enable_slot() Date: Thu, 20 May 2021 11:24:07 +0200 Message-Id: <20210520092108.222974065@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 6727471ea5b4..d0f5c526c8e6 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