[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190810004458.mio4vp3nk6jl2hyh@master>
Date: Sat, 10 Aug 2019 00:44:58 +0000
From: Wei Yang <richard.weiyang@...il.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Wei Yang <richard.weiyang@...il.com>,
"Schmid, Carsten" <Carsten_Schmid@...tor.com>,
"bp@...e.de" <bp@...e.de>,
"dan.j.williams@...el.com" <dan.j.williams@...el.com>,
"mingo@...nel.org" <mingo@...nel.org>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"bhelgaas@...gle.com" <bhelgaas@...gle.com>,
"osalvador@...e.de" <osalvador@...e.de>,
"rdunlap@...radead.org" <rdunlap@...radead.org>,
"richardw.yang@...ux.intel.com" <richardw.yang@...ux.intel.com>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
Subject: Re: Resend [PATCH] kernel/resource.c: invalidate parent when freed
resource has childs
On Fri, Aug 09, 2019 at 03:45:59PM -0700, Linus Torvalds wrote:
>On Fri, Aug 9, 2019 at 3:38 PM Wei Yang <richard.weiyang@...il.com> wrote:
>>
>> In theory, child may have siblings. Would it be possible to have several
>> devices under xhci-hcd?
>
>I'm less interested in the xhci-hcd case - which I certainly *hope* is
>fixed already? - than in "if this happens somewhere else".
>
Agree, this is what I want to say.
>So if we do want to remove the parent (which may be a good idea with a
>warning), and want to make sure that the children are really removed
>from the resource hierarchy, we should do somethiing like
>
> static bool detach_children(struct resource *res)
> {
> res = res->child;
> if (!res)
> return false;
> do {
> res->parent = NULL;
> res = res->sibling;
> } while (res);
> return true;
> }
>
>and then we could write the __release_region() warning as
>
> /* You should not release a resource that has children */
> WARN_ON_ONCE(detach_children(res));
>
I am thinking about why this could happen.
To guard the core kernel code, it looks reasonable.
>or something?
>
>NOTE! The above is entirely untested, and written purely in my mail
>reader. It might be seriously buggy, including not compiling, or doing
>odd things. See it more as a "maybe something like this" code snippet
>example than any kind of final form.
>
> Linus
--
Wei Yang
Help you, Help me
Powered by blists - more mailing lists