[PATCH RESEND v2 05/51] xtensa: simdisk: remove the proc entry before the disk
From: Christian Brauner
Date: Wed Nov 04 2026 - 14:44:53 EST
simdisk_teardown() frees the gendisk and only then removes
/proc/simdisk/<n>. A write to that entry in between attaches the file
that was written to the disk, and simdisk_attach() sets the capacity of
the gendisk that is gone. Remove the entry first, remove_proc_entry()
waits for a writer that is in the middle of that.
Fixes: b6c7e873daf7 ("xtensa: ISS: add host file-based simulated disk")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
---
arch/xtensa/platforms/iss/simdisk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/xtensa/platforms/iss/simdisk.c b/arch/xtensa/platforms/iss/simdisk.c
index a2ddb49c269d..e51edb8cf872 100644
--- a/arch/xtensa/platforms/iss/simdisk.c
+++ b/arch/xtensa/platforms/iss/simdisk.c
@@ -379,12 +379,13 @@ static void simdisk_teardown(struct simdisk *dev, int which,
{
char tmp[2] = { '0' + which, 0 };
+ /* a write to the entry attaches a file to the disk, so it goes first */
+ remove_proc_entry(tmp, procdir);
simdisk_detach(dev);
if (dev->gd) {
del_gendisk(dev->gd);
put_disk(dev->gd);
}
- remove_proc_entry(tmp, procdir);
}
static void __exit simdisk_exit(void)
--
2.53.0