Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4539156rdb; Fri, 15 Sep 2023 05:33:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVTmZkpExKUSU2SadTi3VmC1pxmNnR3ceuvMXTOjB/C1eOI6I5MVuDNcGEb3PV9Yu2JSwj X-Received: by 2002:a17:90b:1d8a:b0:268:ca76:64a with SMTP id pf10-20020a17090b1d8a00b00268ca76064amr1146428pjb.49.1694781208844; Fri, 15 Sep 2023 05:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694781208; cv=none; d=google.com; s=arc-20160816; b=MRlu+xQ9yURfjP4EKwYMDmmLrFcQmmfuRfaFTD/EO4ADF0sC21exOMIm8KyDNNnFI3 UvqMIfHzisHOz8STPuZ1iIVO929GPwcA8+eaLlemc7Fufi9ErHv2jVqQb0O+4rceq5Ld A/HXgNm6vrFZJJO15ue2QK3ZKQA6qPeB/0aKrgpnsdV2fv9NYIIMaPTDcmqfxxC6VRxW 1dg+Ab8WqAFGK+lov28/LuEQgyvhEPPLLySfWT898qzR3hE7FIcw3kUlsNo1z4hpkT2g JGLwnqr8RvhcIRHo2yecUbsGw5KrhnGgeyBdzgfXczks5aMfN8se+JKKgJV8RjUEWEtj gZ9A== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=PmvGks0+KQ3RgHLvTFqwqlkwpj3IXsAouo/gs54hY7M=; fh=zxmBU0vIX0d+bqtF8S9rDsLCePI7roSiIOPr9R1WvJo=; b=xfpaEDgBCdyCcTkNUs39wFUgGTtjBIBqANiIDQJF9t5UOVU5euCa5YfmoSCCIez4JG uF0dQ2PXbMF/4bSCGVcuztLbQ+Egs7b5VZXQ5HUWw3vGRMjZmpXfO+BiKXYN0hqMkav2 kKEL+CA0XRu4L6fHJ13EoFufUGkzPxsIweRF/ljpNP2fTlbsy4FcZpFMSg5dI804shZp AhucGvyqe6esyxTm2uJW872Exi14gmpKqSjQHTaRziI4bKIL1lqFXBS/+NyIMdqfsB5h BaBuZ5vFPrfoUcOS9+Z5n9igda4xH5FdGLAl8YA0caHHgY7PVMwkBx3LIJFOTmU/bl1U RUSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ATeOeyhG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id bv21-20020a17090af19500b00274b23c2867si51080pjb.58.2023.09.15.05.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 05:33:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ATeOeyhG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7018A83B6E1B; Fri, 15 Sep 2023 00:05:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232242AbjIOHE7 (ORCPT + 99 others); Fri, 15 Sep 2023 03:04:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjIOHE7 (ORCPT ); Fri, 15 Sep 2023 03:04:59 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 848A8E0; Fri, 15 Sep 2023 00:04:53 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9CB0DFF802; Fri, 15 Sep 2023 07:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1694761492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PmvGks0+KQ3RgHLvTFqwqlkwpj3IXsAouo/gs54hY7M=; b=ATeOeyhGyvH0B4r2O6LXDZBmWhZoBHS25Y+sjVOm3LOGfmdf309G3G5/Dsq9vEw5uRQ26o 4a6Azm929v7RYDXOdYiZGF6ijDhZTSjirctpM1veP2IMh0m4aD/f+eOCbk24MfOmdPXixE Qy539ox9yt2YhXdN0q0FWzcCohSpKCob2iuCCXB0hyOPu1GtzM4GXqqS869nDxBpuuOhKD 7216eLLn6HG3srL5EACl03Dwxct7I/63O8Ng+lpF6dKCjsToXs8eAfN6niqiqgRxAAHZ54 KMbH4GM7kYTJfIkECYtJhLOq0MsbhaOmkCdyQVrjEinZg/f09Ft4J21uhxcrDQ== Date: Fri, 15 Sep 2023 09:04:50 +0200 From: Herve Codina To: Lizhi Hou Cc: , , , , Subject: Re: [PATCH] PCI: of: Fix memory leak when of_changeset_create_node() failed Message-ID: <20230915090450.206657cf@bootlin.com> In-Reply-To: <1694715351-58279-1-git-send-email-lizhi.hou@amd.com> References: <1694715351-58279-1-git-send-email-lizhi.hou@amd.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: herve.codina@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 15 Sep 2023 00:05:01 -0700 (PDT) Hi Lizhi On Thu, 14 Sep 2023 11:15:51 -0700 Lizhi Hou wrote: > Destroy and free cset when failure happens. > > Fixes: 407d1a51921e ("PCI: Create device tree node for bridge") > Reported-by: Herve Codina > Closes: https://lore.kernel.org/all/20230911171319.495bb837@bootlin.com/ > Signed-off-by: Lizhi Hou > --- > drivers/pci/of.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/of.c b/drivers/pci/of.c > index 2af64bcb7da3..67bbfa2fca59 100644 Why this patch alone ? The issue fixed by this patch is related to the patch 2 in a series under review https://lore.kernel.org/linux-kernel/ZQGaSr+G5qu%2F8nJZ@smile.fi.intel.com/ Is the patch 2 in this series already applied by some maintainers ? You have to fix the patch in the series sending a new iteration of the series. This patch alone does not make sense. Otherwise, the modifications to fix the issue seem good. Regards, Hervé > --- a/drivers/pci/of.c > +++ b/drivers/pci/of.c > @@ -663,7 +663,6 @@ void of_pci_make_dev_node(struct pci_dev *pdev) > np = of_changeset_create_node(cset, ppnode, name); > if (!np) > goto failed; > - np->data = cset; > > ret = of_pci_add_properties(pdev, cset, np); > if (ret) > @@ -673,12 +672,17 @@ void of_pci_make_dev_node(struct pci_dev *pdev) > if (ret) > goto failed; > > + np->data = cset; > pdev->dev.of_node = np; > kfree(name); > > return; > > failed: > + if (cset) { > + of_changeset_destroy(cset); > + kfree(cset); > + } > if (np) > of_node_put(np); > kfree(name);