From: Conor Dooley <conor.dooley@microchip.com>
To: <stable@vger.kernel.org>
Cc: <conor@kernel.org>, <conor.dooley@microchip.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Greentime Hu <greentime.hu@sifive.com>,
Zong Li <zong.li@sifive.com>,
Palmer Dabbelt <palmer@rivosinc.com>,
Sasha Levin <sashal@kernel.org>,
Yang Yingliang <yangyingliang@huawei.com>
Subject: [PATCH 5.15 3/3] soc: sifive: l2_cache: fix missing of_node_put() in sifive_l2_init()
Date: Fri, 21 Apr 2023 14:58:18 +0100 [thread overview]
Message-ID: <20230421-legibly-unbeaten-45bc950de85e@wendy> (raw)
In-Reply-To: <20230421-scam-karma-3de5bf7904b3@wendy>
From: Yang Yingliang <yangyingliang@huawei.com>
commit 8fbf94fea0b4e187ca9100936c5429f96b8a4e44 upstream.
The device_node pointer returned by of_find_matching_node() with
refcount incremented, when finish using it, the refcount need be
decreased.
Fixes: a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
[conor: cache -> l2_cache]
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/soc/sifive/sifive_l2_cache.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/soc/sifive/sifive_l2_cache.c b/drivers/soc/sifive/sifive_l2_cache.c
index 1248127009f6..783158070490 100644
--- a/drivers/soc/sifive/sifive_l2_cache.c
+++ b/drivers/soc/sifive/sifive_l2_cache.c
@@ -202,12 +202,16 @@ static int __init sifive_l2_init(void)
if (!np)
return -ENODEV;
- if (of_address_to_resource(np, 0, &res))
- return -ENODEV;
+ if (of_address_to_resource(np, 0, &res)) {
+ rc = -ENODEV;
+ goto err_node_put;
+ }
l2_base = ioremap(res.start, resource_size(&res));
- if (!l2_base)
- return -ENOMEM;
+ if (!l2_base) {
+ rc = -ENOMEM;
+ goto err_node_put;
+ }
intr_num = of_property_count_u32_elems(np, "interrupts");
if (!intr_num) {
@@ -224,6 +228,7 @@ static int __init sifive_l2_init(void)
goto err_free_irq;
}
}
+ of_node_put(np);
l2_config_read();
@@ -240,6 +245,8 @@ static int __init sifive_l2_init(void)
free_irq(g_irq[i], NULL);
err_unmap:
iounmap(l2_base);
+err_node_put:
+ of_node_put(np);
return rc;
}
device_initcall(sifive_l2_init);
--
2.39.2
prev parent reply other threads:[~2023-04-21 14:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-21 13:58 [PATCH 5.15 0/3] sifive ccache error handling backports for 5.15 Conor Dooley
2023-04-21 13:58 ` [PATCH 5.15 1/3] soc: sifive: l2_cache: fix missing iounmap() in error path in sifive_l2_init() Conor Dooley
2023-04-21 13:58 ` [PATCH 5.15 2/3] soc: sifive: l2_cache: fix missing free_irq() " Conor Dooley
2023-04-23 13:11 ` Greg Kroah-Hartman
2023-04-24 9:30 ` Conor Dooley
2023-04-21 13:58 ` Conor Dooley [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230421-legibly-unbeaten-45bc950de85e@wendy \
--to=conor.dooley@microchip.com \
--cc=conor@kernel.org \
--cc=greentime.hu@sifive.com \
--cc=gregkh@linuxfoundation.org \
--cc=palmer@rivosinc.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=yangyingliang@huawei.com \
--cc=zong.li@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox