From patchwork Fri Jul 1 11:26:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang He X-Patchwork-Id: 12903203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4102EC43334 for ; Fri, 1 Jul 2022 11:27:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234108AbiGAL11 (ORCPT ); Fri, 1 Jul 2022 07:27:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231503AbiGAL1Z (ORCPT ); Fri, 1 Jul 2022 07:27:25 -0400 Received: from mail-m964.mail.126.com (mail-m964.mail.126.com [123.126.96.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6DA66814A5 for ; Fri, 1 Jul 2022 04:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=YS3HD oiFxyAoNpF4CK5ulUAvVzxrypMS5E6OHvbV/UQ=; b=bGQpEJEp1uV0JM5twlKrK 4pkc5KlulOCqYZh5bp8datHayWk74EoZN+BM6cVexuCplrW/uafQbXIhkTspu/X2 xBanEIoqve/XO8FDZbWftvLsowL6rJy0r99yHh8MnTwrOfVjcY96j/faC/i3vnD5 YLgnv54EJ49tSYcyTpHlWw= Received: from localhost.localdomain (unknown [124.16.139.61]) by smtp9 (Coremail) with SMTP id NeRpCgAHJtD62b5ibZSuFw--.17397S2; Fri, 01 Jul 2022 19:26:52 +0800 (CST) From: Liang He To: tony@atomide.com, linux@armlinux.org.uk, linux-omap@vger.kernel.org, windhl@126.com Subject: [PATCH 1/3] crypto: nx: Hold the reference returned by of_find_compatible_node Date: Fri, 1 Jul 2022 19:26:47 +0800 Message-Id: <20220701112649.233322-1-windhl@126.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: NeRpCgAHJtD62b5ibZSuFw--.17397S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7Xr1UAry5AFykur17Kr4rKrg_yoWDZwb_CF 929ry7ZFWj9rs3XrsxZr43ZryYv3yfur48Zrn2v343t3y7Zr47WFn8JF1xZ348Wry8JFZx ZwsYyr17Gr43ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRWpBSUUUUUU== X-Originating-IP: [124.16.139.61] X-CM-SenderInfo: hzlqvxbo6rjloofrz/1tbizhwxF18RPabT7QAAsf Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org In nx842_pseries_init(), we should hold the reference returned by of_find_compatible_node() and use it to call of_node_put to keep refcount balance. Signed-off-by: Liang He --- drivers/crypto/nx/nx-common-pseries.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/nx/nx-common-pseries.c b/drivers/crypto/nx/nx-common-pseries.c index 7584a34ba88c..3ea334b7f820 100644 --- a/drivers/crypto/nx/nx-common-pseries.c +++ b/drivers/crypto/nx/nx-common-pseries.c @@ -1208,10 +1208,13 @@ static struct vio_driver nx842_vio_driver = { static int __init nx842_pseries_init(void) { struct nx842_devdata *new_devdata; + struct device_node *np; int ret; - if (!of_find_compatible_node(NULL, NULL, "ibm,compression")) + np = of_find_compatible_node(NULL, NULL, "ibm,compression"); + if (!np) return -ENODEV; + of_node_put(np); RCU_INIT_POINTER(devdata, NULL); new_devdata = kzalloc(sizeof(*new_devdata), GFP_KERNEL); From patchwork Fri Jul 1 11:26:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang He X-Patchwork-Id: 12903207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0FE0C433EF for ; Fri, 1 Jul 2022 11:28:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234586AbiGAL2q (ORCPT ); Fri, 1 Jul 2022 07:28:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233360AbiGAL2o (ORCPT ); Fri, 1 Jul 2022 07:28:44 -0400 Received: from mail-m964.mail.126.com (mail-m964.mail.126.com [123.126.96.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8998B13DEF for ; Fri, 1 Jul 2022 04:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=HK0Ux GmbKcMBQFG6B2BMlrbdPZBNhKOypZTXeCTRJho=; b=gw0JN7l815K03g0p2koyb c+eUXP9sl9DIr11ol7BlUK2SiR+vfeabhaDhSpmCntvIJEudNmyyf5CtbXnIPI1I 3uHNOj9cw21Mzt6lgu8BEhDt1sbcMyo62kQLUW3dgg72uDFKbn25IssjMgy05Ilp syF8PvsyKrq751TmwdiBvA= Received: from localhost.localdomain (unknown [124.16.139.61]) by smtp9 (Coremail) with SMTP id NeRpCgAHJtD62b5ibZSuFw--.17397S3; Fri, 01 Jul 2022 19:26:53 +0800 (CST) From: Liang He To: tony@atomide.com, linux@armlinux.org.uk, linux-omap@vger.kernel.org, windhl@126.com Subject: [PATCH 2/3] arm: omap2: pm33xx-core: Fix missing of_node_put() in amx3_idle_init() Date: Fri, 1 Jul 2022 19:26:48 +0800 Message-Id: <20220701112649.233322-2-windhl@126.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220701112649.233322-1-windhl@126.com> References: <20220701112649.233322-1-windhl@126.com> MIME-Version: 1.0 X-CM-TRANSID: NeRpCgAHJtD62b5ibZSuFw--.17397S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Gry7Cr4rCw4UZFyxKFWDtwb_yoWktrc_Ww 1I9397Jr4rtw10gFZ8uan5WwnYywn7GrZrXryIkF4qkayjvFW7X39xW34xKFWUWFWYkrW3 trs7Xw129w15tjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRAHUDDUUUUU== X-Originating-IP: [124.16.139.61] X-CM-SenderInfo: hzlqvxbo6rjloofrz/1tbi3B0xF1pED1yKCAAAso Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org To keep refcount balance, we need to call of_node_put() for the reference 'state_node' returned by of_parse_phandle() in fail path or when it is not used anymore. Signed-off-by: Liang He --- arch/arm/mach-omap2/pm33xx-core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-omap2/pm33xx-core.c b/arch/arm/mach-omap2/pm33xx-core.c index bf0d25fd2cea..58b98a17746c 100644 --- a/arch/arm/mach-omap2/pm33xx-core.c +++ b/arch/arm/mach-omap2/pm33xx-core.c @@ -393,12 +393,15 @@ static int __init amx3_idle_init(struct device_node *cpu_node, int cpu) if (!state_node) break; - if (!of_device_is_available(state_node)) + if (!of_device_is_available(state_node)) { + of_node_put(state_node); continue; + } if (i == CPUIDLE_STATE_MAX) { pr_warn("%s: cpuidle states reached max possible\n", __func__); + of_node_put(state_node); break; } @@ -408,6 +411,7 @@ static int __init amx3_idle_init(struct device_node *cpu_node, int cpu) states[state_count].wfi_flags |= WFI_FLAG_WAKE_M3 | WFI_FLAG_FLUSH_CACHE; + of_node_put(state_node); state_count++; } From patchwork Fri Jul 1 11:26:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang He X-Patchwork-Id: 12903204 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75354C433EF for ; Fri, 1 Jul 2022 11:27:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230467AbiGAL11 (ORCPT ); Fri, 1 Jul 2022 07:27:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232785AbiGAL1Z (ORCPT ); Fri, 1 Jul 2022 07:27:25 -0400 Received: from mail-m964.mail.126.com (mail-m964.mail.126.com [123.126.96.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4A99081482 for ; Fri, 1 Jul 2022 04:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=n5laP LCGGMBzjX7p1cAZ7VYDOFKgvmLjT5x79mPRnrM=; b=FavUmXTKT/5wPUg5MjMq1 eugVlUFwpKumMHjjANW98Yfy9Oa1qbBa+DGceB82pw0N97eGhlPfqfRPN0R4rMK6 uG2mG2KLDjrkb2Tkv07K4zrSn0nv5Pkxm6T1HXxqe6E553DpNtaYBDRLgo2AE1p6 wpW4c1X65zmw5zf3efS/Yk= Received: from localhost.localdomain (unknown [124.16.139.61]) by smtp9 (Coremail) with SMTP id NeRpCgAHJtD62b5ibZSuFw--.17397S4; Fri, 01 Jul 2022 19:26:54 +0800 (CST) From: Liang He To: tony@atomide.com, linux@armlinux.org.uk, linux-omap@vger.kernel.org, windhl@126.com Subject: [PATCH 3/3] arm: omap2: prm_common: Add the refcount for new reference creation Date: Fri, 1 Jul 2022 19:26:49 +0800 Message-Id: <20220701112649.233322-3-windhl@126.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220701112649.233322-1-windhl@126.com> References: <20220701112649.233322-1-windhl@126.com> MIME-Version: 1.0 X-CM-TRANSID: NeRpCgAHJtD62b5ibZSuFw--.17397S4 X-Coremail-Antispam: 1Uf129KBjvdXoW7JF47Kr1ktr4fGw48JryfXrb_yoWfXFbE9w n2ga4kJr18Ga1Ig3ZrJa1fWr1Dta4rGr9rG34kJ3W5Ka90qr43CrZYyayIv347uFW2krZr JrZrZryYkw1jvjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRED73JUUUUU== X-Originating-IP: [124.16.139.61] X-CM-SenderInfo: hzlqvxbo6rjloofrz/1tbiuB4xF2JVkJ3ejQAAsp Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org In omap2_prm_base_init(), for_each_matching_node_and_match() can automatically increase and decrease the refcounting. However, a new reference is escaped out into 'data->np', so we need to use of_node_put() for the old reference and use of_node_get() for the new one. Signed-off-by: Liang He --- arch/arm/mach-omap2/prm_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c index fb2d48cfe756..bed151e3f165 100644 --- a/arch/arm/mach-omap2/prm_common.c +++ b/arch/arm/mach-omap2/prm_common.c @@ -764,7 +764,8 @@ int __init omap2_prm_base_init(void) prm_base.pa = res.start + data->offset; } - data->np = np; + of_node_put(data->np); + data->np = of_node_get(np); if (data->init) data->init(data);