Message ID | 20221018023149.1048176-4-yangyingliang@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Conor Dooley |
Headers | show |
Series | some fixes for sifive_ccache | expand |
On Tue, Oct 18, 2022 at 10:31:49AM +0800, Yang Yingliang wrote: > The device_node pointer returned by of_find_matching_node() with > refcount incremented, when finish using it, the refcount need be > decreased. Cool, patch looks about as I'd expect. Thanks! Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > > Fixes: a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs") > 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 98269d056728..3684f5b40a80 100644 > --- a/drivers/soc/sifive/sifive_ccache.c > +++ b/drivers/soc/sifive/sifive_ccache.c > @@ -215,12 +215,16 @@ static int __init sifive_ccache_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; > + } > > ccache_base = ioremap(res.start, resource_size(&res)); > - if (!ccache_base) > - return -ENOMEM; > + if (!ccache_base) { > + rc = -ENOMEM; > + goto err_node_put; > + } > > if (of_property_read_u32(np, "cache-level", &level)) { > rc = -ENOENT; > @@ -243,6 +247,7 @@ static int __init sifive_ccache_init(void) > goto err_free_irq; > } > } > + of_node_put(np); > > ccache_config_read(); > > @@ -259,6 +264,8 @@ static int __init sifive_ccache_init(void) > free_irq(g_irq[i], NULL); > err_unmap: > iounmap(ccache_base); > +err_node_put: > + of_node_put(np); > return rc; > } > > -- > 2.25.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv
diff --git a/drivers/soc/sifive/sifive_ccache.c b/drivers/soc/sifive/sifive_ccache.c index 98269d056728..3684f5b40a80 100644 --- a/drivers/soc/sifive/sifive_ccache.c +++ b/drivers/soc/sifive/sifive_ccache.c @@ -215,12 +215,16 @@ static int __init sifive_ccache_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; + } ccache_base = ioremap(res.start, resource_size(&res)); - if (!ccache_base) - return -ENOMEM; + if (!ccache_base) { + rc = -ENOMEM; + goto err_node_put; + } if (of_property_read_u32(np, "cache-level", &level)) { rc = -ENOENT; @@ -243,6 +247,7 @@ static int __init sifive_ccache_init(void) goto err_free_irq; } } + of_node_put(np); ccache_config_read(); @@ -259,6 +264,8 @@ static int __init sifive_ccache_init(void) free_irq(g_irq[i], NULL); err_unmap: iounmap(ccache_base); +err_node_put: + of_node_put(np); return rc; }
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> --- drivers/soc/sifive/sifive_ccache.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)