[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <eaf5e27b-696f-bede-520c-cf6a847a5250@gmail.com>
Date: Thu, 19 Dec 2019 09:33:00 -0600
From: Frank Rowand <frowand.list@...il.com>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Rob Herring <robh@...nel.org>
Cc: devicetree@...r.kernel.org,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Michael Ellerman <mpe@...erman.id.au>,
Segher Boessenkool <segher@...nel.crashing.org>,
Frank Rowand <frowand.list@...il.com>
Subject: Re: [PATCH] of: Rework and simplify phandle cache to use a fixed size
On 12/12/19 7:05 AM, Sebastian Andrzej Siewior wrote:
> On 2019-12-11 17:48:54 [-0600], Rob Herring wrote:
>>> - if (phandle_cache) {
>>> - if (phandle_cache[masked_handle] &&
>>> - handle == phandle_cache[masked_handle]->phandle)
>>> - np = phandle_cache[masked_handle];
>>> - if (np && of_node_check_flag(np, OF_DETACHED)) {
>>> - WARN_ON(1); /* did not uncache np on node removal */
>>> - of_node_put(np);
>>> - phandle_cache[masked_handle] = NULL;
>>> - np = NULL;
>>> - }
>>> + if (phandle_cache[handle_hash] &&
>>> + handle == phandle_cache[handle_hash]->phandle)
>>> + np = phandle_cache[handle_hash];
>>> + if (np && of_node_check_flag(np, OF_DETACHED)) {
>>> + WARN_ON(1); /* did not uncache np on node removal */
>>
>> BTW, I don't think this check is even valid. If we failed to detach
>> and remove the node from the cache, then we could be accessing np
>> after freeing it.
>
> this is kmalloc()ed memory which is always valid. If the memory is
It was kmalloc()ed memory _before_ applying Rob's patch. It no longer
is kmalloc()ed, so the rest of this discussion no longer applies.
-Frank
> already re-used then
> handle == phandle_cache[handle_hash]->phandle
>
> will fail (the check, not the memory access itself). If the check
> remains valid then you can hope for the OF_DETACHED flag to trigger the
> warning.
>
>> Rob
>
> Sebastian
>
Powered by blists - more mailing lists