Re: [PATCH/RFC 3/3] of/dynamic: Update list of aliases on aliases changes

From: Geert Uytterhoeven
Date: Wed Jul 01 2015 - 02:53:54 EST


Hi Grant,

On Tue, Jun 30, 2015 at 7:21 PM, Grant Likely <grant.likely@xxxxxxxxxx> wrote:
> On Tue, 30 Jun 2015 16:51:16 +0200
> , Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> wrote:
>> Currently the list of aliases is not updated when an overlay that
>> modifies /aliases is added or removed. This breaks drivers (e.g. serial)
>> that rely on of_alias_get_id().
>>
>> Update the list of aliases when a property of the /aliases node is
>> added, removed, or updated.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>

>> - Is it safe to deallocate struct alias_prop using kfree()? It may
>> have been allocated using early_init_dt_alloc_memory_arch() /
>> memblock_alloc(). What's the alternative? Leaking memory?
>
> Properties are not refcounted, so yes we leak memory. The memory remains
> owned by the aliases node, but because the aliases node is never freed,
> neither are any of the properties. Solving this isn't easy because it
> would require adding refcounting *everywhere* that properties are
> accessed. I think we have to just live with it until someone clever can
> some up with a solution.

Please note that struct alias_prop is not a property, but a list_head.
Hence it's not added to the deadprops of a node, and it isn't owned by
anyone after removal from the aliases_lookup list.
I can create a new dead_aliases list for that, if that's what needed...

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/