On Wed, 19 Jul 2023 at 11:12, Kjetil Oftedal <oftedal@xxxxxxxxx> wrote: > > On Tue, 18 Jul 2023 at 11:10, <sunran001@xxxxxxxxxx> wrote: > > > > The of_find_device_by_node() takes a reference to the underlying device > > structure, we should release that reference. > > > > ./arch/sparc/kernel/of_device_common.c:36:1-7: ERROR: missing > > put_device; call of_find_device_by_node on line 30, but without a > > corresponding object release within this function. > > ./arch/sparc/kernel/of_device_common.c:50:1-7: ERROR: missing > > put_device; call of_find_device_by_node on line 42, but without a > > corresponding object release within this function. > > > > Signed-off-by: Ran Sun <sunran001@xxxxxxxxxx> > > --- > > arch/sparc/kernel/of_device_common.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/arch/sparc/kernel/of_device_common.c > > b/arch/sparc/kernel/of_device_common.c > > index 7851307de6d0..5e9847d0fbed 100644 > > --- a/arch/sparc/kernel/of_device_common.c > > +++ b/arch/sparc/kernel/of_device_common.c > > @@ -33,8 +33,8 @@ int of_address_to_resource(struct device_node *node, > > int index, > > if (!op || index >= op->num_resources) > > return -EINVAL; > > > > - put_device(op->dev); > > memcpy(r, &op->archdata.resource[index], sizeof(*r)); > > + put_device(op->dev); > > return 0; > > } > > EXPORT_SYMBOL_GPL(of_address_to_resource); > > @@ -47,8 +47,8 @@ void __iomem *of_iomap(struct device_node *node, int > > index) > > if (!op || index >= op->num_resources) > > return NULL; > > > > - put_device(op->dev); > > r = &op->archdata.resource[index]; > > + put_device(op->dev); > > > > return of_ioremap(r, 0, resource_size(r), (char *) r->name); > > } > > > Based on Dmitry Baryshkov earlier comment I am not sure if this is a safe fix. > (And I am not fully knowledgable about the memory lifecycle here) > > If it is so that the device can disappear after put_device, is it then > safe to access a > pointer to that devices resource information when calling of_ioremap() ? No, r, being a pointer to device's archdata, can also be gone. Also, I'd note to Ran Sun, that sending an unversioned fix for a fix is frowned upon. Please send a proper versioned patch with the included changelog, etc. I think I have already pointed you to Documentation/process/ files. Please read them carefully and follow them, otherwise your further patches can get ignored/NAKed. -- With best wishes Dmitry