Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=dcec4c3bdc4d5f4bd2d858ee1ce11e3424cbaed7
Commit:     dcec4c3bdc4d5f4bd2d858ee1ce11e3424cbaed7
Parent:     bbf25010f1a6b761914430f5fca081ec8c7accd1
Author:     Florin Malita <[EMAIL PROTECTED]>
AuthorDate: Thu Jul 19 15:22:41 2007 -0400
Committer:  Artem Bityutskiy <[EMAIL PROTECTED]>
CommitDate: Sun Oct 14 13:10:20 2007 +0300

    UBI: fix leak in ubi_scan_erase_peb
    
    Coverity (1769) found the following problem: if the erase counter
    overflow check triggers, ec_hdr is leaked.
    
    Moving the allocation after the overflow check should take care of it.
    
    Signed-off-by: Florin Malita <[EMAIL PROTECTED]>
    Signed-off-by: Artem Bityutskiy <[EMAIL PROTECTED]>
---
 drivers/mtd/ubi/scan.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 94ee549..80c73d8 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -673,10 +673,6 @@ int ubi_scan_erase_peb(const struct ubi_device *ubi,
        int err;
        struct ubi_ec_hdr *ec_hdr;
 
-       ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);
-       if (!ec_hdr)
-               return -ENOMEM;
-
        if ((long long)ec >= UBI_MAX_ERASECOUNTER) {
                /*
                 * Erase counter overflow. Upgrade UBI and use 64-bit
@@ -686,6 +682,10 @@ int ubi_scan_erase_peb(const struct ubi_device *ubi,
                return -EINVAL;
        }
 
+       ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);
+       if (!ec_hdr)
+               return -ENOMEM;
+
        ec_hdr->ec = cpu_to_be64(ec);
 
        err = ubi_io_sync_erase(ubi, pnum, 0);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to