Message ID | 20230102094733.3966825-1-linmq006@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4089861wrt; Mon, 2 Jan 2023 01:52:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXskC2hAHNhGSWPhHdb9q2LznKbClUcER+8SwA3PgivYDPMVnz3G4cAWq7B2vgIGM4t8YTns X-Received: by 2002:a05:6a20:e68a:b0:af:c491:d4ba with SMTP id mz10-20020a056a20e68a00b000afc491d4bamr42861691pzb.53.1672653174464; Mon, 02 Jan 2023 01:52:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672653174; cv=none; d=google.com; s=arc-20160816; b=Skzh/hMQc/o8m+GumiCr4Pga+81Two0ptO45md60NkS7cgkM8P37Kqxg0RzZt8McG4 jWoiWCQ4ZzXDrUozmA5dOaOUzFjx3aZ79CWLoMZKWQ5x5pPryYTd9H6T071A39e/6GFm mv+TgfKD24e20gJiAb1tNo22FZ2r0Ufa5qKkDHJRZ0A35DfbAvtejVpEYPVb7y0Nz7i9 /tMvHswrM5pNj1CUYRUiqYYIAn0c7tYxmLSYeC+8Y91pPsWWJUPZB8EzH0EG6Hng3rQ8 BNcL9/nTmM3FVnuiJOJ43oPV7GHBY4/Ej5MoGp1FUj510z6pxtyf6fFLJNhS8xFGEJL1 ICng== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=CBwV2mkPeuz+bYwsA3f6iWrfsv26cm3nPyYFJXVroCI=; b=uT3+HHFNSIEAzC1PIoXBGhh67MO96N032zNaBI0rMEcwV5Is0unmJ8tZuCEfNV9UYH wMBqc6qecv2iW4vE5nPXLPrwzFRA+tDU6rjXLBVbbws+mUMp+R+1OLEsdfn2N/ak/Bq3 YxJJBJeFtxHi/7PGVpFF7khg/qfPPkE3u+d49q/UvAFfiRpVrDm8H1z7/oRddBTv/j9/ pkrLWsacJ10U8kOwW0u/PTzyI7IXA0YhFl1GXNJHIo2HVR+gHKY00Nzf3c7yVV7mnfuu s3n8GSA80hXP6b3LapVhVxPY9AnmdauTM64xyBKxg7Grzeqav8ZTd5rp176veZvjH25/ n+eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=L1GQsIa5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s142-20020a632c94000000b0049cb7f59cc4si15329460pgs.132.2023.01.02.01.52.40; Mon, 02 Jan 2023 01:52:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=L1GQsIa5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232419AbjABJtA (ORCPT <rfc822;cscallsign@gmail.com> + 99 others); Mon, 2 Jan 2023 04:49:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232401AbjABJro (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 2 Jan 2023 04:47:44 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3801210D8 for <linux-kernel@vger.kernel.org>; Mon, 2 Jan 2023 01:47:41 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id d15so29113872pls.6 for <linux-kernel@vger.kernel.org>; Mon, 02 Jan 2023 01:47:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=CBwV2mkPeuz+bYwsA3f6iWrfsv26cm3nPyYFJXVroCI=; b=L1GQsIa5xrmYZGgAyxeLqivX7wIoYwpsiTB1C5osf6lUMQcy4xMYrCh5bGHv23iMUH aYwJG9jkt3q3I/E9VTmUKmhjhcAOFwmjBu8KI8OAs8299HFjYj22ZZoV4GNm2FkfmqY0 eoCEB+pHOmT94kiaEoh6ga7TVlFzcWbSw+VSWFTqh+48i5TG5btjUSmi4KJnQGDImt29 K69yGGsiL2sgyDcwrIO+ifiX42lfgdUmp8xZdUbNACvUWoB66M9WeJibunHS792JBWaV gux2K/UsBvaU7s/8ocP84EvfOO8RPG5OLAaUk6+l9NhVWHCgZ0tibJKPnkEdD0ZCiGmA dkAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CBwV2mkPeuz+bYwsA3f6iWrfsv26cm3nPyYFJXVroCI=; b=fGCMfcFlXDx4Y2s0wqvT6QWfk5LJyx/anGXezwNGP+UeolujRp1jO+y5XTOYmtSrro oWCmqIO9ahRzHMZ2ABz6nrBshzcz1zGqf87m4L7NOdjXHscSH9xMZw+fyR7v00POPneo 3/WbAy1JOxvnqCUOrglIEIllJrVHE3aGcslSj4L6KY6f/lJHh+LNBfom8aMIcnKoS4ce ASb3g1uSwlahdwkqo/gOy3f92dcRiCjxcn3NWWVIG2D0SvkmY6HXaDAePBvHrhwyl6qG lX+0ykEllV2i1tsx02nM26orfLXv4r6EkNT7245TxtpHY0j+JMuwxIKglsgzU723aETW n4DA== X-Gm-Message-State: AFqh2kr3gTO0rHlOCReo6h9CRm5jh3KntKQJ5styaFml5UofYjfMJFZF 6wzKauzlog8qVQppr0LQRfiWuoY50VF9vsHE X-Received: by 2002:a05:6a20:3b0f:b0:af:e129:cb7 with SMTP id c15-20020a056a203b0f00b000afe1290cb7mr44296616pzh.52.1672652861448; Mon, 02 Jan 2023 01:47:41 -0800 (PST) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id t66-20020a635f45000000b0046feb2754e5sm16607991pgb.28.2023.01.02.01.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jan 2023 01:47:40 -0800 (PST) From: Miaoqian Lin <linmq006@gmail.com> To: Linus Walleij <linus.walleij@linaro.org>, Russell King <linux@armlinux.org.uk>, Ulf Hansson <ulf.hansson@linaro.org>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linmq006@gmail.com Subject: [PATCH] ARM: ux500: Fix refcount leak in ux500_pm_domains_init Date: Mon, 2 Jan 2023 13:47:33 +0400 Message-Id: <20230102094733.3966825-1-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, SUSPICIOUS_RECIPS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753903975070816250?= X-GMAIL-MSGID: =?utf-8?q?1753903975070816250?= |
Series |
ARM: ux500: Fix refcount leak in ux500_pm_domains_init
|
|
Commit Message
Miaoqian Lin
Jan. 2, 2023, 9:47 a.m. UTC
of_irq_find_parent() returns a node pointer with refcount incremented,
We should use of_node_put() on it when not needed anymore.
Add missing of_node_put() in the error path to avoid refcount leak.
Fixes: cd931dcfda5e ("ARM: ux500: Initial support for PM domains")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
arch/arm/mach-ux500/pm_domains.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Mon, 2 Jan 2023 at 10:47, Miaoqian Lin <linmq006@gmail.com> wrote: > > of_irq_find_parent() returns a node pointer with refcount incremented, Probably a cut and paste, as you probably mean of_find_matching_node(). > We should use of_node_put() on it when not needed anymore. > Add missing of_node_put() in the error path to avoid refcount leak. > > Fixes: cd931dcfda5e ("ARM: ux500: Initial support for PM domains") > Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Other than the above, which maybe Linus can fixup when applying: Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Kind regards Uffe > --- > arch/arm/mach-ux500/pm_domains.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/mach-ux500/pm_domains.c b/arch/arm/mach-ux500/pm_domains.c > index 427b9ac4af6c..01cae91854ca 100644 > --- a/arch/arm/mach-ux500/pm_domains.c > +++ b/arch/arm/mach-ux500/pm_domains.c > @@ -65,8 +65,10 @@ int __init ux500_pm_domains_init(void) > return -ENODEV; > > genpd_data = kzalloc(sizeof(*genpd_data), GFP_KERNEL); > - if (!genpd_data) > + if (!genpd_data) { > + of_node_put(np); > return -ENOMEM; > + } > > genpd_data->domains = ux500_pm_domains; > genpd_data->num_domains = ARRAY_SIZE(ux500_pm_domains); > -- > 2.25.1 >
On Mon, Jan 2, 2023 at 10:47 AM Miaoqian Lin <linmq006@gmail.com> wrote: > of_irq_find_parent() returns a node pointer with refcount incremented, > We should use of_node_put() on it when not needed anymore. > Add missing of_node_put() in the error path to avoid refcount leak. > > Fixes: cd931dcfda5e ("ARM: ux500: Initial support for PM domains") > Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Patch applied. Sorry for forgetting about this patch! Yours, Linus Walleij
diff --git a/arch/arm/mach-ux500/pm_domains.c b/arch/arm/mach-ux500/pm_domains.c index 427b9ac4af6c..01cae91854ca 100644 --- a/arch/arm/mach-ux500/pm_domains.c +++ b/arch/arm/mach-ux500/pm_domains.c @@ -65,8 +65,10 @@ int __init ux500_pm_domains_init(void) return -ENODEV; genpd_data = kzalloc(sizeof(*genpd_data), GFP_KERNEL); - if (!genpd_data) + if (!genpd_data) { + of_node_put(np); return -ENOMEM; + } genpd_data->domains = ux500_pm_domains; genpd_data->num_domains = ARRAY_SIZE(ux500_pm_domains);