[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250322-initrd-erofs-v2-2-d66ee4a2c756@cyberus-technology.de>
Date: Sat, 22 Mar 2025 21:34:14 +0100
From: Julian Stecklina via B4 Relay <devnull+julian.stecklina.cyberus-technology.de@...nel.org>
To: Christoph Hellwig <hch@....de>, Al Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>, Gao Xiang <xiang@...nel.org>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-erofs@...ts.ozlabs.org,
Julian Stecklina <julian.stecklina@...erus-technology.de>
Subject: [PATCH v2 2/9] initrd: fix double fput for truncated ramdisks
From: Julian Stecklina <julian.stecklina@...erus-technology.de>
When you actually take the exit via devblocks == 0, the code will do
fput(in_file) twice. This was introduced when the APIs where switched
to the file-based APIs.
Remove more of the multi-floppy support from the olden days.
Fixes: bef173299613 ("initrd: switch initrd loading to struct file based APIs")
Signed-off-by: Julian Stecklina <julian.stecklina@...erus-technology.de>
---
init/do_mounts_rd.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index 473f4f9417e157118b9a6e582607435484d53d63..d026df401afa0b7458ab1f266b21830aab974b92 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -234,20 +234,20 @@ int __init rd_load_image(char *from)
goto done;
}
+ if (devblocks < nblocks) {
+ printk(KERN_ERR "RAMDISK: looks truncated: (%luKiB vs %dKiB) - continuing anyway\n",
+ devblocks, nblocks);
+ nblocks = devblocks;
+ }
+
buf = kmalloc(BLOCK_SIZE, GFP_KERNEL);
if (!buf) {
printk(KERN_ERR "RAMDISK: could not allocate buffer\n");
goto done;
}
- printk(KERN_NOTICE "RAMDISK: Loading %dKiB [%ld disk%s] into ram disk... ",
- nblocks, ((nblocks-1)/devblocks)+1, nblocks>devblocks ? "s" : "");
+ printk(KERN_NOTICE "RAMDISK: Loading %dKiB into ram disk... ", nblocks);
for (i = 0; i < nblocks; i++) {
- if (i && (i % devblocks == 0)) {
- pr_cont("done disk #1.\n");
- fput(in_file);
- break;
- }
kernel_read(in_file, buf, BLOCK_SIZE, &in_pos);
kernel_write(out_file, buf, BLOCK_SIZE, &out_pos);
}
--
2.47.0
Powered by blists - more mailing lists