[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK8P3a3MmTi7Nbo986FPy9E_zRXXVaGFYmBbChPqd8pEu6wfZA@mail.gmail.com>
Date: Mon, 26 Jun 2017 14:28:14 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Zhongping Tan (谭中平)
<Zhongping.Tan@...eadtrum.com>
Cc: Orson Zhai (翟京)
<Orson.Zhai@...eadtrum.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH] char: misc: Init misc->list in a safe way
On Mon, Jun 26, 2017 at 1:48 PM, Zhongping Tan (谭中平)
<Zhongping.Tan@...eadtrum.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
Powered by blists - more mailing lists