From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79B4CC433ED for ; Thu, 8 Apr 2021 15:19:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 408496113E for ; Thu, 8 Apr 2021 15:19:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232187AbhDHPTO (ORCPT ); Thu, 8 Apr 2021 11:19:14 -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-Google-Smtp-Source: ABdhPJwVEMJhK8+sgSmB9cm72hb4M6W0oHnJovlQTNy7RP187o2yTsTnPnRWXrah2/JAZTIkhMHC1ggeWpqDECdKj+o= 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-pci@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 >