UBI: Return -ENOMEM upon failing malloc
Subsystems (2)
PATCH 1/1 UBI: Return -ENOMEM upon failing malloc
Return with correct error code (-ENOMEM) from ubi_attach_mtd_dev() upon failing malloc().
Signed-off-by Stefan Roese <[email protected]>
--- drivers/mtd/ubi/build.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
drivers/mtd/ubi/build.c +11 -5
@@ -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);
Signature · 1 line
1.6.0.5
Quoted 7 lines · Stefan Roese
Return with correct error code (
-ENOMEM) fromubi_attach_mtd_dev()upon failingmalloc().Signed-off-by Stefan Roese <[email protected]>--- drivers/mtd/ubi/build.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
Thanks for the patch. I've improved it a little bit and pushed:
http://git.infradead.org/users/dedekind/ubi-2.6.git?a=commit;h=ad5942bad6addcf9697a74413b517d9724d803a4
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)