linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Michael Schmitz <schmitzmic@gmail.com>,
	linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org,
	Christoph Hellwig <hch@lst.de>,
	Finn Thain <fthain@linux-m68k.org>
Subject: Re: [PATCH v2] ataflop: remove ataflop_probe_lock mutex
Date: Thu, 21 Oct 2021 09:20:06 -0700	[thread overview]
Message-ID: <YXGTNjhWfVjsB9A8@bombadil.infradead.org> (raw)
In-Reply-To: <5524e6ee-e469-9775-07c4-7baf5e330148@i-love.sakura.ne.jp>

On Sun, Oct 17, 2021 at 11:09:47AM +0900, Tetsuo Handa wrote:
> Commit bf9c0538e485b591 ("ataflop: use a separate gendisk for each media
> format") introduced ataflop_probe_lock mutex, but forgot to unlock the
> mutex when atari_floppy_init() (i.e. module loading) succeeded. This will
> result in double lock deadlock if ataflop_probe() is called. Also,
> unregister_blkdev() must not be called from atari_floppy_init() with
> ataflop_probe_lock held when atari_floppy_init() failed, for
> ataflop_probe() waits for ataflop_probe_lock with major_names_lock held
> (i.e. AB-BA deadlock).
> 
> __register_blkdev() needs to be called last in order to avoid calling
> ataflop_probe() when atari_floppy_init() is about to fail, for memory for
> completing already-started ataflop_probe() safely will be released as soon
> as atari_floppy_init() released ataflop_probe_lock mutex.
> 
> As with commit 8b52d8be86d72308 ("loop: reorder loop_exit"),
> unregister_blkdev() needs to be called first in order to avoid calling
> ataflop_alloc_disk() from ataflop_probe() after del_gendisk() from
> atari_floppy_exit().
> 
> By relocating __register_blkdev() / unregister_blkdev() as explained above,
> we can remove ataflop_probe_lock mutex, for probe function and __exit
> function are serialized by major_names_lock mutex.
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Fixes: bf9c0538e485b591 ("ataflop: use a separate gendisk for each media format")

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>

  Luis

  parent reply	other threads:[~2021-10-21 16:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-16 13:25 [PATCH] ataflop: unlock ataflop_probe_lock at atari_floppy_init() Tetsuo Handa
2021-10-16 22:56 ` Finn Thain
2021-10-17  1:52 ` Michael Schmitz
2021-10-17  2:09   ` [PATCH v2] ataflop: remove ataflop_probe_lock mutex Tetsuo Handa
2021-10-17 19:05     ` Michael Schmitz
2021-10-17 23:47       ` Michael Schmitz
2021-10-18  8:15         ` Michael Schmitz
2021-10-18 22:25     ` Michael Schmitz
2021-10-21 16:20     ` Luis Chamberlain [this message]
2021-10-21 16:21       ` Luis Chamberlain

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=YXGTNjhWfVjsB9A8@bombadil.infradead.org \
    --to=mcgrof@kernel.org \
    --cc=fthain@linux-m68k.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=schmitzmic@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).