From patchwork Wed Dec 10 09:42:54 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 13146 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 64A58474C1 for ; Wed, 10 Dec 2008 20:44:43 +1100 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1LALat-0003CB-0h; Wed, 10 Dec 2008 09:42:59 +0000 Received: from moutng.kundenserver.de ([212.227.126.171]) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1LALar-000347-2T for linux-mtd@lists.infradead.org; Wed, 10 Dec 2008 09:42:57 +0000 Received: from localhost.localdomain (achn-4db49ab4.pool.einsundeins.de [77.180.154.180]) by mrelayeu.kundenserver.de (node=mrelayeu4) with ESMTP (Nemesis) id 0ML21M-1LALao3swe-0000O0; Wed, 10 Dec 2008 10:42:56 +0100 From: Stefan Roese To: linux-mtd@lists.infradead.org Subject: [PATCH] UBI: Return -ENOMEM upon failing malloc Date: Wed, 10 Dec 2008 10:42:54 +0100 Message-Id: <1228902174-24597-1-git-send-email-sr@denx.de> X-Mailer: git-send-email 1.6.0.5 X-Provags-ID: V01U2FsdGVkX18HF2/IblLdJnO86hCEm/DA9k52Cv7b18MkrzC szlEESilMXzUenu1X+NlxJ3Pqd6cIZkxAmdqm1qGDq1Pa267j1 SCaQM9Wv4S3HfYM8cKQAzEFWaX5xJqr X-Spam-Score: 0.0 (/) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@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);