diff mbox series

Fixed a crash caused by CONFIG_JFFS2_FS_WBUF_VERIFY not allocating memory to Wbuf_Verify under UBI.

Message ID 1635911831-38364-1-git-send-email-yongjianxiao@yeah.net
State Deferred
Delegated to: Richard Weinberger
Headers show
Series Fixed a crash caused by CONFIG_JFFS2_FS_WBUF_VERIFY not allocating memory to Wbuf_Verify under UBI. | expand

Commit Message

YongjianXion Nov. 3, 2021, 3:57 a.m. UTC
Signed-off-by: YongjianXion <yongjianxiao@yeah.net>
---
 fs/jffs2/wbuf.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index c6821a50..59d6169 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -1342,9 +1342,19 @@  int jffs2_ubivol_setup(struct jffs2_sb_info *c) {
 	pr_info("write-buffering enabled buffer (%d) erasesize (%d)\n",
 		c->wbuf_pagesize, c->sector_size);
 
+#ifdef CONFIG_JFFS2_FS_WBUF_VERIFY
+	c->wbuf_verify = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
+	if (!c->wbuf_verify) {
+		kfree(c->wbuf);
+		return -ENOMEM;
+	}
+#endif
 	return 0;
 }
 
 void jffs2_ubivol_cleanup(struct jffs2_sb_info *c) {
+#ifdef CONFIG_JFFS2_FS_WBUF_VERIFY
+	kfree(c->wbuf_verify);
+#endif
 	kfree(c->wbuf);
 }