Skip to contentSkip to conversation

UBI: Return -ENOMEM upon failing malloc

PATCH New Stefan Roese 1 participant 1 message Dec 10, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 UBI: Return -ENOMEM upon failing malloc

Return with correct error code (-ENOMEM) from ubi_attach_mtd_dev() upon failing malloc().

Thanks to Michael Lawnick for pointing this out.

---
v2:
- Slightly improved version

 drivers/mtd/ubi/build.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/mtd/ubi/build.c +3 -2
index bdf75c9..f4b01a9 100644
@@ -784,19 +784,20 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
 	if (err)
 		goto out_free;
 
+	err = -ENOMEM;
 	ubi->peb_buf1 = vmalloc(ubi->peb_size);
 	if (!ubi->peb_buf1)
 		goto out_free;
 
 	ubi->peb_buf2 = vmalloc(ubi->peb_size);
 	if (!ubi->peb_buf2)
-		 goto out_free;
+		goto out_free;
 
 #ifdef CONFIG_MTD_UBI_DEBUG
 	mutex_init(&ubi->dbg_buf_mutex);
 	ubi->dbg_peb_buf = vmalloc(ubi->peb_size);
 	if (!ubi->dbg_peb_buf)
-		 goto out_free;
+		goto out_free;
 #endif
 
 	err = attach_by_scanning(ubi);
Signature · 1 line
1.6.0.5