Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1674647
| From | Zhongping Tan (谭中平) <Zhongping.Tan@spreadtrum.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | RE: [RFC PATCH] char: misc: Init misc->list in a safe way |
| Date | 2017-06-26 13:50 +0200 |
| Message-ID | <tWAGK-1PD-5@gated-at.bofh.it> (permalink) |
| References | <tWyEW-Ba-21@gated-at.bofh.it> <tWz7Z-10D-47@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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.
-----Original Message-----
From: arndbergmann@gmail.com [mailto:arndbergmann@gmail.com] On Behalf Of Arnd Bergmann
Sent: Monday, June 26, 2017 6:03 PM
To: Orson Zhai (翟京)
Cc: Greg Kroah-Hartman; Linux Kernel Mailing List; Zhongping Tan (谭中平)
Subject: Re: [RFC PATCH] char: misc: Init misc->list in a safe way
On Mon, Jun 26, 2017 at 11:31 AM, Orson Zhai <orson.zhai@spreadtrum.com> wrote:
> From: Zhongping Tan <zhongping.tan@spreadtrum.com>
>
> It is likely to enter a wrong case and return an error when
> registerring a misc device. As a result, misc->list will be intialized
> to a dead loop which is possible to go into wrong situation if anyone
> refers to it else where.
>
> Move the initializion line out of all error branches to avoid any side
> effect.
>
> Signed-off-by: Zhongping Tan <zhongping.tan@spreadtrum.com>
> Signed-off-by: Orson Zhai <orson.zhai@spreadtrum.com>
I fail to see the problem. Did you run into a bug that gets fixed by this patch, or did you arrive here after code inspection?
As far as I can tell, the INIT_LIST_HEAD() on the entry has no effect at all, the fields simply get initialized in the list_add(), and the list traversal is protected using misc_mtx.
Arnd
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC PATCH] char: misc: Init misc->list in a safe way Orson Zhai <orson.zhai@spreadtrum.com> - 2017-06-26 11:40 +0200
Re: [RFC PATCH] char: misc: Init misc->list in a safe way Arnd Bergmann <arnd@arndb.de> - 2017-06-26 12:10 +0200
RE: [RFC PATCH] char: misc: Init misc->list in a safe way Zhongping Tan (谭中平) <Zhongping.Tan@spreadtrum.com> - 2017-06-26 13:50 +0200
Re: [RFC PATCH] char: misc: Init misc->list in a safe way Arnd Bergmann <arnd@arndb.de> - 2017-06-26 14:30 +0200
Re: 答复: [RFC PATCH] char: misc: Init misc->list in a safe way Arnd Bergmann <arnd@arndb.de> - 2017-06-26 16:20 +0200
RE: 答复: [RFC PATCH] char: misc: Init misc->list in a safe way Zhongping Tan (谭中平) <Zhongping.Tan@spreadtrum.com> - 2017-06-27 04:10 +0200
Re: 答复: [RFC PATCH] char: misc: Init misc->list in a safe way Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 08:30 +0200
Re: [RFC PATCH] char: misc: Init misc->list in a safe way Orson Zhai <orson.zhai@spreadtrum.com> - 2017-06-28 04:00 +0200
Re: [RFC PATCH] char: misc: Init misc->list in a safe way Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-28 07:20 +0200
Re: [RFC PATCH] char: misc: Init misc->list in a safe way Arnd Bergmann <arnd@arndb.de> - 2017-06-28 12:40 +0200
Re: [RFC PATCH] char: misc: Init misc->list in a safe way Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-28 13:30 +0200
Re: [RFC PATCH] char: misc: Init misc->list in a safe way Chunyan Zhang <zhang.lyra@gmail.com> - 2017-06-29 09:00 +0200
Re: [RFC PATCH] char: misc: Init misc->list in a safe way Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-29 09:10 +0200
Re: [RFC PATCH] char: misc: Init misc->list in a safe way Chunyan Zhang <zhang.lyra@gmail.com> - 2017-06-29 09:40 +0200
csiph-web