From patchwork Wed Dec 10 09:42:54 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: UBI: Return -ENOMEM upon failing malloc Date: Tue, 09 Dec 2008 23:42:54 -0000 From: Stefan Roese X-Patchwork-Id: 13146 Message-Id: <1228902174-24597-1-git-send-email-sr@denx.de> To: linux-mtd@lists.infradead.org Return with correct error code (-ENOMEM) from ubi_attach_mtd_dev() upon failing malloc(). Signed-off-by: Stefan Roese --- drivers/mtd/ubi/build.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index c7630a2..485c0fc 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -816,18 +816,24 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) goto out_free; ubi->peb_buf1 = vmalloc(ubi->peb_size); - if (!ubi->peb_buf1) + if (!ubi->peb_buf1) { + err = -ENOMEM; goto out_free; + } ubi->peb_buf2 = vmalloc(ubi->peb_size); - if (!ubi->peb_buf2) - goto out_free; + if (!ubi->peb_buf2) { + err = -ENOMEM; + 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; + if (!ubi->dbg_peb_buf) { + err = -ENOMEM; + goto out_free; + } #endif err = attach_by_scanning(ubi);