[PATCH] Fixed a crash caused by CONFIG_JFFS2_FS_WBUF_VERIFY not allocating memory to Wbuf_Verify under UBI.
YongjianXion
yongjianxiao at yeah.net
Tue Nov 2 20:57:11 PDT 2021
Signed-off-by: YongjianXion <yongjianxiao at yeah.net>
---
fs/jffs2/wbuf.c | 10 ++++++++++
1 file changed, 10 insertions(+)
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);
}
--
2.7.4
More information about the linux-mtd
mailing list