From: dayou5941@163.com
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org, liyouhong <liyouhong@kylinos.cn>
Subject: [PATCH] loop: clear backing file on LOOP_CONFIGURE limits failure
Date: Thu, 23 Jul 2026 15:33:47 +0800 [thread overview]
Message-ID: <20260723073347.2129494-1-dayou5941@163.com> (raw)
From: liyouhong <liyouhong@kylinos.cn>
loop_configure() assigns the backing file before queue_limits_commit_update().
If the limits update fails (e.g. an invalid block_size), the error path
fput()s the file but leaves lo->lo_backing_file set, keeps the modified
mapping gfp mask, leaves lo->lo_device dangling, and never clears the
uevent suppression flag.
Undo the assign on that failure path.
Fixes: b38c8be255e8 ("loop: use queue_limits_commit_update() for configuring")
Assisted-by: Cursor:grok-4.5
Signed-off-by: liyouhong <liyouhong@kylinos.cn>
---
drivers/block/loop.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 1faecef33009..bfe2a788db44 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1059,7 +1059,7 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
/* No need to freeze the queue as the device isn't bound yet. */
error = queue_limits_commit_update(lo->lo_queue, &lim);
if (error)
- goto out_unlock;
+ goto out_clear_backing;
/*
* We might switch to direct I/O mode for the loop device, write back
@@ -1096,6 +1096,11 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
return 0;
+out_clear_backing:
+ mapping_set_gfp_mask(file->f_mapping, lo->old_gfp_mask);
+ lo->lo_backing_file = NULL;
+ lo->lo_device = NULL;
+ dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 0);
out_unlock:
loop_global_unlock(lo, is_loop);
out_bdev:
reply other threads:[~2026-07-23 7:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260723073347.2129494-1-dayou5941@163.com \
--to=dayou5941@163.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=liyouhong@kylinos.cn \
/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