mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Zhongping Tan (谭中平)" <Zhongping.Tan@spreadtrum.com>
To: "Arnd Bergmann" <arnd@arndb.de>,
	"Orson Zhai (翟京)" <Orson.Zhai@spreadtrum.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: RE: [RFC PATCH] char: misc: Init misc->list in a safe way
Date: Mon, 26 Jun 2017 11:48:14 +0000	[thread overview]
Message-ID: <f556152beaac4a6ab91cd9029eaf00fc@SHMBX02.spreadtrum.com> (raw)
In-Reply-To: <CAK8P3a3H5E487CeaCzFRoEpzQfFePZK+z0nQ6HEDtWJN7t=NAA@mail.gmail.com>

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

  reply	other threads:[~2017-06-26 11:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26  9:31 Orson Zhai
2017-06-26 10:02 ` Arnd Bergmann
2017-06-26 11:48   ` Zhongping Tan (谭中平) [this message]
2017-06-26 12:28     ` Arnd Bergmann
     [not found]       ` <ca76fa84d77449bf84c2f3ddf29048a0@SHMBX02.spreadtrum.com>
2017-06-26 14:10         ` 答复: " Arnd Bergmann
2017-06-27  2:02           ` Zhongping Tan (谭中平)
2017-06-27  6:29             ` Greg Kroah-Hartman
2017-06-28  1:54               ` Orson Zhai
2017-06-28  5:18                 ` Greg Kroah-Hartman
2017-06-28 10:34                   ` Arnd Bergmann
2017-06-28 11:21                     ` Greg Kroah-Hartman
2017-06-29  6:54                       ` Chunyan Zhang
2017-06-29  7:03                         ` Greg Kroah-Hartman
2017-06-29  7:30                           ` Chunyan Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f556152beaac4a6ab91cd9029eaf00fc@SHMBX02.spreadtrum.com \
    --to=zhongping.tan@spreadtrum.com \
    --cc=Orson.Zhai@spreadtrum.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome