Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4200560rdb; Thu, 14 Sep 2023 15:16:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3BOdImOdLloJKHTkMOuDWSt8IU0Vn/slN5V2diH4UczskIdwBdr1VWP3ZiJ40/uGjZMxA X-Received: by 2002:a05:6358:7f05:b0:134:c785:5932 with SMTP id p5-20020a0563587f0500b00134c7855932mr68391rwn.32.1694729815747; Thu, 14 Sep 2023 15:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694729815; cv=none; d=google.com; s=arc-20160816; b=umwTDYm2rXAPPNJO6hjVuJ+vGNwAdkr3FC26sKA62azDaXokktb9Y7AobtPnp/keMh PVREMIUZDtXDMrBGSdvcUROz3SDVzbOr+T+EVQYnIQkHCrASpeBZ4Uo51s/P+hGGkQIJ +W3BB0HE9j7soRjKoFnPyLvZy+S0R5aySITq/B5AyERU+9ccfn4S3i1t5pF+2/aypE/R HEj0xIEjc5xjP8poDgR5/A2vMVlaDUTb+Q006Kl+R/Yd4tK6oivBCLnBB4AnHyvXPesI rYqH3rgN55LHiYJwjF+c68wW8zmMQUtXwscBgP2TVqbAusQ1JfIlLHc/9eOhnplRHVzT kTlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=wxM/CRoD3JKaVnkmsw2ndIN0bmN3lKAlmmoxIO/1ADQ=; fh=Jjsq1EblH0g93MyIOKHqsCXWBx2wsk+CbmXkczT6ug8=; b=W4ipXO4l6S8bGFQ+ZTbgfx4Ukoae63AyHOy+IUm5hClrM9N1YTCY2KMcbUuL3pToW/ APBarGr4s/OT7aPGoFMjdym56XQIlGPeep5NpDtYRs82270QAe03J4CjE5xgYKza/RhH kJgdiYzI3KLdupA2CM/mTDlf6y0r01OwxmxsWhj+9mZ4xxKJRuLoqVsVb3aQM1ukRHKe RU4XAwEazpbdiWRyBWJH4lRuqILy4PGTqh+eF0Sg5d/WTKGpTPj6jlKLxSVt+kILBjwf +5hiQGLInHMH1WuR+c9awG7ZBnSSzfREg0k7CbWNTXyBacZWAsN5psJzY7JVfw8wc61Z YyEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=db84Z3l2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id w6-20020a637b06000000b005696a8e371csi2019711pgc.35.2023.09.14.15.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 15:16:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=db84Z3l2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7BA118295357; Thu, 14 Sep 2023 09:10:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235264AbjINQKr (ORCPT + 99 others); Thu, 14 Sep 2023 12:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232594AbjINQKq (ORCPT ); Thu, 14 Sep 2023 12:10:46 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F85F1BF8 for ; Thu, 14 Sep 2023 09:10:42 -0700 (PDT) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38EG8qJs010389; Thu, 14 Sep 2023 16:10:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=wxM/CRoD3JKaVnkmsw2ndIN0bmN3lKAlmmoxIO/1ADQ=; b=db84Z3l2Ma3GLDVNLusEIncP22DwWYdzo1c3anhq3g0GCzkhTFQogQCG1lsVgVro71dO Lp8+phjrmaihwlCsZ8NkkXbpkIEF3eLc+sAlgNpcUwAghQKAPjCGfZcKrg2QoMIMP63P Oecb6eBo3QZQ1pJ23J1YM0nXKx4JNQ8lB0K7iSEPoIby+EevnAg+JBW2BryVf7PfK8Iy O7lpkhypPOdIpel520S30TLm0AKnu4BdmEr8Moo5m/35su29IfHOPnD3FtQ+99M3GEVJ cGPua7kgKXzzXxMU6H+s/DDIolg3QtNEJvpjFyNvIWAdk9x5YdthZyZZB7ibyVulE4xC rQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3t4584rax5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Sep 2023 16:10:27 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 38EG9ZlL017308; Thu, 14 Sep 2023 16:10:27 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3t4584rasy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Sep 2023 16:10:26 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 38EECXUc024033; Thu, 14 Sep 2023 16:10:25 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3t131tmjax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Sep 2023 16:10:25 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 38EGAOH83342852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Sep 2023 16:10:24 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF31A58051; Thu, 14 Sep 2023 16:10:24 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2CC2E5805C; Thu, 14 Sep 2023 16:10:24 +0000 (GMT) Received: from [9.61.37.125] (unknown [9.61.37.125]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 14 Sep 2023 16:10:24 +0000 (GMT) Message-ID: <54bf92e8-f884-1567-2149-caf638ff8f68@linux.ibm.com> Date: Thu, 14 Sep 2023 09:10:23 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH 1/1] powerpc: fix a memory leak Content-Language: en-US To: Yuanjun Gong , Michael Ellerman , Nicholas Piggin , Christophe Leroy , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20230914094620.3379729-1-ruc_gongyuanjun@163.com> From: Tyrel Datwyler In-Reply-To: <20230914094620.3379729-1-ruc_gongyuanjun@163.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ehf7fiFyzaUOI7NGdKsAxMSqMMcW1_UN X-Proofpoint-ORIG-GUID: ZG1ahKUKrOA4vxNeAv_OcJngxTe42jz- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-14_09,2023-09-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 clxscore=1011 malwarescore=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309140139 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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 09:10:49 -0700 (PDT) X-Spam-Status: No, score=-2.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, 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 lipwig.vger.email On 9/14/23 02:46, Yuanjun Gong wrote: > When one of the methods xive_native_alloc_irq_on_chip, irq_create_mapping > or irq_get_handler_data fails, the function will directly return without > disposing vinst->name and vinst. Fix it. > > Fixes: c20e1e299d93 ("powerpc/vas: Alloc and setup IRQ and trigger port address") > Signed-off-by: Yuanjun Gong > --- > arch/powerpc/platforms/powernv/vas.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/arch/powerpc/platforms/powernv/vas.c b/arch/powerpc/platforms/powernv/vas.c > index b65256a63e87..780740b478f0 100644 > --- a/arch/powerpc/platforms/powernv/vas.c > +++ b/arch/powerpc/platforms/powernv/vas.c > @@ -54,7 +54,7 @@ static int init_vas_instance(struct platform_device *pdev) > struct xive_irq_data *xd; > uint32_t chipid, hwirq; > struct resource *res; > - int rc, cpu, vasid; > + int rc, cpu, vasid, ret; You can you reuse rc for the return value in the error path instead of introducing a new ret variable. -Tyrel > > rc = of_property_read_u32(dn, "ibm,vas-id", &vasid); > if (rc) { > @@ -102,6 +102,7 @@ static int init_vas_instance(struct platform_device *pdev) > res = &pdev->resource[3]; > if (res->end > 62) { > pr_err("Bad 'paste_win_id_shift' in DT, %llx\n", res->end); > + ret = -ENODEV > goto free_vinst; > } > > @@ -111,21 +112,24 @@ static int init_vas_instance(struct platform_device *pdev) > if (!hwirq) { > pr_err("Inst%d: Unable to allocate global irq for chip %d\n", > vinst->vas_id, chipid); > - return -ENOENT; > + ret = -ENOENT; > + goto free_vinst; > } > > vinst->virq = irq_create_mapping(NULL, hwirq); > if (!vinst->virq) { > pr_err("Inst%d: Unable to map global irq %d\n", > vinst->vas_id, hwirq); > - return -EINVAL; > + ret = -EINVAL; > + goto free_vinst; > } > > xd = irq_get_handler_data(vinst->virq); > if (!xd) { > pr_err("Inst%d: Invalid virq %d\n", > vinst->vas_id, vinst->virq); > - return -EINVAL; > + ret = -EINVAL; > + goto free_vinst; > } > > vinst->irq_port = xd->trig_page; > @@ -168,7 +172,7 @@ static int init_vas_instance(struct platform_device *pdev) > free_vinst: > kfree(vinst->name); > kfree(vinst); > - return -ENODEV; > + return ret; > > } >