On Tue, May 21, 2024 at 10:42:48PM +0000, Gulam Mohamed wrote: > Description > =========== That's a weird way to format a patch. Between this and the odd subject not matching patch 2 I was tricked into thinking this was just a cover letter and patch 1 was missing for a while. Please take a look at other patches/commit and try to word it similarly. > V1->V2: > Added a test case, 010, in blktests in tests/loop/ These kind of patch revision changelogs belong after the --- so that they don't go into git history. Or even better into the cover letter, which is missing here. > Signed-off-by: Gulam Mohamed <gulam.mohamed@xxxxxxxxxx> > --- > drivers/block/loop.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/drivers/block/loop.c b/drivers/block/loop.c > index 28a95fd366fe..9a235d8c062d 100644 > --- a/drivers/block/loop.c > +++ b/drivers/block/loop.c > @@ -1717,6 +1717,24 @@ static int lo_compat_ioctl(struct block_device *bdev, blk_mode_t mode, > } > #endif > > +static int lo_open(struct gendisk *disk, blk_mode_t mode) > +{ > + struct loop_device *lo = disk->private_data; > + int err; > + > + if (!lo) > + return -ENXIO; ->private_data is never cleared, so the NULL check here doesn't make sense. > + err = mutex_lock_killable(&lo->lo_mutex); > + if (err) > + return err; > + > + if (lo->lo_state == Lo_rundown) > + err = -ENXIO; > + mutex_unlock(&lo->lo_mutex); What if we race with setting Lo_rundown and that gets set right after we unlock here?