[patch] ubifs: potential uninitialized variable in truncate_data_node()

Dan Carpenter dan.carpenter at oracle.com
Thu Jan 5 04:46:35 PST 2017


GCC doesn't complain, but my static checker warns that if the data is
not compressed and not encrypted then "ret" isn't initialized.

Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>

diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index a459211a1c21..c54f04d88236 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -1281,7 +1281,8 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
 			      int *new_len)
 {
 	void *buf;
-	int err, dlen, compr_type, out_len, old_dlen;
+	int dlen, compr_type, out_len, old_dlen;
+	int err = 0;
 
 	out_len = le32_to_cpu(dn->size);
 	buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS);



More information about the linux-mtd mailing list