lkml.org 
[lkml]   [2017]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RFC PATCH] char: misc: Init misc->list in a safe way
On Mon, Jun 26, 2017 at 1:48 PM, Zhongping Tan (谭中平)
<Zhongping.Tan@spreadtrum.com> wrote:
> Hi Arnd:
> If we can get list_add(&misc->list, &misc_list), then there is no problem at all, but if the misc_register return "-EBUSY"(Maybe the same miscdevice register twice ), then the deadloop will happen at list_for_each_entry(c, &misc_list, list);
> So at my opinion just remove the initialization code or do initialization when we need do list_add.

I think you are misinterpreting a bug you see: the pointer we pass
into misc_register() must not already be registered, which means that
nothing references misc->list at all.

If misc_register() returns success, and you then call it another time,
you will see the exact behavior that you describe, entering an endless
loop in "list_for_each_entry(c, &misc_list, list)". The correct fix for that
is in the calling code, to ensure that the same device can not get
registered multiple times.

Arnd

\
 
 \ /
  Last update: 2017-06-26 14:29    [W:0.066 / U:0.948 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site