Commit 4ddb85d
ataflop: remove ataflop_probe_lock mutex
Commit bf9c053 ("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 8b52d8b ("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: bf9c053 ("ataflop: use a separate gendisk for each media format")
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Link: https://lore.kernel.org/r/20211103230437.1639990-11-mcgrof@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>1 parent ed73919 commit 4ddb85d
1 file changed
+27
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2008 | 2008 | | |
2009 | 2009 | | |
2010 | 2010 | | |
2011 | | - | |
2012 | | - | |
2013 | 2011 | | |
2014 | 2012 | | |
2015 | 2013 | | |
| |||
2020 | 2018 | | |
2021 | 2019 | | |
2022 | 2020 | | |
2023 | | - | |
2024 | 2021 | | |
2025 | 2022 | | |
2026 | 2023 | | |
2027 | 2024 | | |
2028 | 2025 | | |
2029 | 2026 | | |
2030 | | - | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
2031 | 2047 | | |
2032 | 2048 | | |
2033 | 2049 | | |
| |||
2053 | 2069 | | |
2054 | 2070 | | |
2055 | 2071 | | |
2056 | | - | |
2057 | | - | |
2058 | | - | |
2059 | | - | |
2060 | | - | |
2061 | 2072 | | |
2062 | 2073 | | |
2063 | 2074 | | |
| |||
2113 | 2124 | | |
2114 | 2125 | | |
2115 | 2126 | | |
2116 | | - | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
2117 | 2133 | | |
2118 | 2134 | | |
2119 | 2135 | | |
2120 | 2136 | | |
2121 | 2137 | | |
2122 | 2138 | | |
2123 | 2139 | | |
2124 | | - | |
2125 | | - | |
2126 | | - | |
2127 | 2140 | | |
2128 | 2141 | | |
2129 | 2142 | | |
| |||
2168 | 2181 | | |
2169 | 2182 | | |
2170 | 2183 | | |
2171 | | - | |
2172 | | - | |
2173 | | - | |
2174 | | - | |
2175 | 2184 | | |
2176 | | - | |
2177 | | - | |
2178 | | - | |
| 2185 | + | |
2179 | 2186 | | |
2180 | 2187 | | |
2181 | 2188 | | |
| |||
0 commit comments