Thread (9 messages) 9 messages, 2 authors, 2021-06-17
STALE1842d

[PATCH v3 1/5] pstore/blk: Improve failure reporting

From: Kees Cook <hidden>
Date: 2021-06-16 16:40:50
Also in: linux-doc, linux-fsdevel, lkml
Subsystem: filesystems (vfs and infrastructure), pstore filesystem, the rest · Maintainers: Alexander Viro, Christian Brauner, Kees Cook, Linus Torvalds

There was no feedback on bad registration attempts. Add details on the
failure cause.

Signed-off-by: Kees Cook <redacted>
---
 fs/pstore/blk.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/fs/pstore/blk.c b/fs/pstore/blk.c
index 4bb8a344957a..eca83820fb5d 100644
--- a/fs/pstore/blk.c
+++ b/fs/pstore/blk.c
@@ -114,8 +114,22 @@ static int __register_pstore_device(struct pstore_device_info *dev)
 
 	lockdep_assert_held(&pstore_blk_lock);
 
-	if (!dev || !dev->total_size || !dev->read || !dev->write)
+	if (!dev) {
+		pr_err("NULL device info\n");
 		return -EINVAL;
+	}
+	if (!dev->total_size) {
+		pr_err("zero sized device\n");
+		return -EINVAL;
+	}
+	if (!dev->read) {
+		pr_err("no read handler for device\n");
+		return -EINVAL;
+	}
+	if (!dev->write) {
+		pr_err("no write handler for device\n");
+		return -EINVAL;
+	}
 
 	/* someone already registered before */
 	if (pstore_zone_info)
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help