From: Yang Yingliang <yangyingliang@huawei.com>
To: Conor Dooley <conor@kernel.org>
Cc: <linux-riscv@lists.infradead.org>, <yash.shah@sifive.com>,
<palmer@dabbelt.com>, <paul.walmsley@sifive.com>,
<yangyingliang@huawei.com>
Subject: Re: [PATCH 1/2] soc: sifive: ccache: fix missing iounmap() in error path in sifive_ccache_init()
Date: Tue, 18 Oct 2022 09:50:34 +0800 [thread overview]
Message-ID: <b9be3d72-dc9d-6f93-3ceb-e3965e98310d@huawei.com> (raw)
In-Reply-To: <Y0145x9Y8MVb1Brw@spud>
Hi Conor,
On 2022/10/17 23:46, Conor Dooley wrote:
> On Mon, Oct 17, 2022 at 04:44:10PM +0800, Yang Yingliang wrote:
>> Add missing iounmap() before return error from sifive_ccache_init().
>>
>> Fixes: a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs")
> Hey Yang Yangliang,
>
> Both of these patches look good to me.
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
>
> One question - of_find_matching_node() increments the refcount of np
> right? It seems to me like we need an of_node_put() here, at the very
> least in the error paths (do we need it in the success path too?).
> If we are going to add cleanup to this driver, we may as well go the
> whole hog I think.
>
> In terms of the success paths, I assume the first place we can safely
> let the reference go is just before the call to ccache_config_read()?
Thanks for reviewing!
Yes, I think you are right, the refcount of np need be put in error paths,
and it's OK to put refcount before ccache_config_read() in normal path.
I can send another patch to fix this.
Thanks,
Yang
>
> Please lmk if I am misunderstanding anything here...
> Thanks,
> Conor.
>
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>> ---
>> drivers/soc/sifive/sifive_ccache.c | 15 +++++++++++----
>> 1 file changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/soc/sifive/sifive_ccache.c b/drivers/soc/sifive/sifive_ccache.c
>> index 1c171150e878..25019c16d8ae 100644
>> --- a/drivers/soc/sifive/sifive_ccache.c
>> +++ b/drivers/soc/sifive/sifive_ccache.c
>> @@ -222,13 +222,16 @@ static int __init sifive_ccache_init(void)
>> if (!ccache_base)
>> return -ENOMEM;
>>
>> - if (of_property_read_u32(np, "cache-level", &level))
>> - return -ENOENT;
>> + if (of_property_read_u32(np, "cache-level", &level)) {
>> + rc = -ENOENT;
>> + goto err_unmap;
>> + }
>>
>> intr_num = of_property_count_u32_elems(np, "interrupts");
>> if (!intr_num) {
>> pr_err("No interrupts property\n");
>> - return -ENODEV;
>> + rc = -ENODEV;
>> + goto err_unmap;
>> }
>>
>> for (i = 0; i < intr_num; i++) {
>> @@ -237,7 +240,7 @@ static int __init sifive_ccache_init(void)
>> NULL);
>> if (rc) {
>> pr_err("Could not request IRQ %d\n", g_irq[i]);
>> - return rc;
>> + goto err_unmap;
>> }
>> }
>>
>> @@ -250,6 +253,10 @@ static int __init sifive_ccache_init(void)
>> setup_sifive_debug();
>> #endif
>> return 0;
>> +
>> +err_unmap:
>> + iounmap(ccache_base);
>> + return rc;
>> }
>>
>> device_initcall(sifive_ccache_init);
>> --
>> 2.25.1
>>
>>
>> _______________________________________________
>> linux-riscv mailing list
>> linux-riscv@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-riscv
> .
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
prev parent reply other threads:[~2022-10-18 1:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-17 8:44 [PATCH 1/2] soc: sifive: ccache: fix missing iounmap() in error path in sifive_ccache_init() Yang Yingliang
2022-10-17 8:44 ` [PATCH 2/2] soc: sifive: ccache: fix missing free_irq() " Yang Yingliang
2022-10-17 15:49 ` Conor Dooley
2022-10-17 15:46 ` [PATCH 1/2] soc: sifive: ccache: fix missing iounmap() " Conor Dooley
2022-10-18 1:50 ` Yang Yingliang [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=b9be3d72-dc9d-6f93-3ceb-e3965e98310d@huawei.com \
--to=yangyingliang@huawei.com \
--cc=conor@kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=yash.shah@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