[PATCH 12/13] fs: pstore: don't free the records when unmounting

Sascha Hauer s.hauer at pengutronix.de
Wed Nov 18 06:52:02 PST 2026


The records belong to pstore rather than to a mount of it: they are
read from the backend once, and every mount of pstore shows the same
list of them. Unmounting pstore frees all of them nevertheless, without
removing them from the list. pstore is mounted on /pstore at startup,
so unmounting another mount of it leaves /pstore with a list of freed
records, and so does unmounting /pstore and mounting it again:

  mount -t pstore none /mnt; umount /mnt; ls /pstore -> use after free

Leave the records alone when unmounting. They are still freed when
removing them with unlink().

Fixes: 160d2ed0ba18 ("fs: Add pstore filesystem")
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 fs/pstore/fs.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c
index 1a0eba4fa4..a5b48a04c0 100644
--- a/fs/pstore/fs.c
+++ b/fs/pstore/fs.c
@@ -208,15 +208,6 @@ static int pstore_stat(struct device *dev, const char *filename,
 	return 0;
 }
 
-static void pstore_remove(struct device *dev)
-{
-	struct pstore_private *d, *tmp;
-
-	list_for_each_entry_safe(d, tmp, &allpstore, list) {
-		free_pstore_private(d);
-	}
-}
-
 static int pstore_probe(struct device *dev)
 {
 	struct list_head *priv = &allpstore;
@@ -243,7 +234,6 @@ static struct fs_driver pstore_driver = {
 	.legacy_ops = &pstore_ops,
 	.drv = {
 		.probe  = pstore_probe,
-		.remove = pstore_remove,
 		.name = "pstore",
 	}
 };

-- 
2.47.3




More information about the barebox mailing list