Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp552682pxf; Thu, 8 Apr 2021 08:22:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5EAX+NPd/OEX4wwYBIlggkmeq/ybpZv+GIpldrsrFmYjqvJOsBWpUNFm8I1fbqgczW5ld X-Received: by 2002:aa7:c683:: with SMTP id n3mr1046944edq.214.1617895376249; Thu, 08 Apr 2021 08:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617895376; cv=none; d=google.com; s=arc-20160816; b=MKBTdfIbHxqq202Jn0XQEmcrmhVz5omNWLfBejq6LOoY99CBs4AkKJ6pOlF43yao/x dZWB59wDmf+nTIIo5sWfvimwWtTcZgFTtCDaTHrIsGaJYJe4yvY82zSmipz6dsRNduGT whshJGpW91650ka+Z6j18Y/x2PEBMvykxula+DBNbbEpe8gbrSDAZu3WK/Q62qlwnR2n t3QiFfEBj0F5JVabozImISlS+KtOFzB6XqzLb6WmxqC7RtM3x8jVG5FDdeaTAaRH3xdR 4fz7fM9IQU7zj2c9wGbdCATU9JAkkJJW3CuFxL0aXEcWwqEYxd/xTRj1ynvL3Z5JwZXt qqFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=NBesEj2fSrr43l9kt9D4AtU33PrnTTnDZIAdB81qk+I=; b=NDSyFD+/D7x7KaMQQ7TDz1koU3O0rzjc/nuzv6mAaDPa3FFIAbPDHX2sA7aszeC1Bp PJ4azrWsdXK6BKuPaslZwpX4fk5WCt8GwpiWZ5GGjGwsR3nNgHoeqJHpxWj0+k//Skry QrAvdsWJ/J+X83wHreh7hBaQgfh53hKW7Nn4OJHPzLiC1cDuGQ3/0ZcDSZnijkn1FMMu BK721Q+NH8b2DQd/BqI9B97BiGW90elOf7JyX5wPyHbrdc1kbHif6hu3sBqq/0Q1alLW cZxsJj+0qwVU5CXpNeVwLHbJXZWSJqsHNCnCVK1nIlDR7/e1exZbg1WOEBqWp4qdp02o I26Q== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si14336757eji.19.2021.04.08.08.22.33; Thu, 08 Apr 2021 08:22:56 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232134AbhDHPTP (ORCPT + 99 others); Thu, 8 Apr 2021 11:19:15 -0400 Received: from mail-oo1-f46.google.com ([209.85.161.46]:46624 "EHLO mail-oo1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232119AbhDHPTI (ORCPT ); Thu, 8 Apr 2021 11:19:08 -0400 Received: by mail-oo1-f46.google.com with SMTP id 125-20020a4a1a830000b02901b6a144a417so578695oof.13; Thu, 08 Apr 2021 08:18:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NBesEj2fSrr43l9kt9D4AtU33PrnTTnDZIAdB81qk+I=; b=B3qsHKK2TooeVj9GZujny0vQo3dEiZ/gZz3nC9nzTfA6UVO6gZ+yKe6uHvv4EnvwyD gXdSTrIN5WEjyTM7Rx9DMFPyiyXoG47kyeB9nSdSri2Vmhh5Qn5mUTMDMvjVtWxswdLS kG46vCHxPRuJMcl3aYlWoE8vaLTIv/5WmuAIxKz2r1BjjqlcCfKiilA44AYKcCfv80Ns m1lFtL2avxe/f0SysLxToEi/mtD07ueJY6dvxwqHv4dsQV8ohzfSQ1OFLHZIAKz4l/LH RGuJtcXcG66IbKMf1X1FYhupa2lQzwWWq4S1I5+usuK6H8nd14b2poTzmVJysOwxe3Rg P7MQ== X-Gm-Message-State: AOAM531OQMHU5I+jptwEeTjSZYhLCiW+r5B/oKeo2Y2rNUmVExmSpxQH Pix5H/ZsoI6D55sLx/lNEJiEetLujcAkQG9ltPG1l7HF X-Received: by 2002:a4a:d48b:: with SMTP id o11mr7919111oos.2.1617895137220; Thu, 08 Apr 2021 08:18:57 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 8 Apr 2021 17:18:46 +0200 Message-ID: Subject: Re: [PATCH v2] ACPI / hotplug / PCI: fix memory leak in enable_slot() To: Zhiqiang Liu , Bjorn Helgaas Cc: "Rafael J. Wysocki" , Len Brown , ACPI Devel Maling List , Linux PCI , "linux-kernel@vger.kernel.org" , linfeilong Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 25, 2021 at 8:27 AM Zhiqiang Liu wrote: > > From: Feilong Lin > > In enable_slot() in drivers/pci/hotplug/acpiphp_glue.c, if pci_get_slot() > will return NULL, we will do not set SLOT_ENABLED flag of slot. if one > device is found by calling pci_get_slot(), its reference count will be > increased. In this case, we did not call pci_dev_put() to decrement the > its reference count, the memory of the device (struct pci_dev type) will > leak. > > Fix it by calling pci_dev_put() to decrement its reference count after that > pci_get_slot() returns a PCI device. > > Signed-off-by: Feilong Lin > Signed-off-by: Zhiqiang Liu > -- > v2: rewrite subject and commit log as suggested by Bjorn Helgaas. The fix is correct AFAICS, so Reviewed-by: Rafael J. Wysocki Bjorn, has this been applied already? If not, do you want me to take it or are you going to queue it up yourself? > --- > 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 >