]> www.infradead.org Git - mtd-utils.git/commitdiff
ftl_check: don't leak temporary buffers
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Sun, 10 Nov 2019 13:51:52 +0000 (14:51 +0100)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Sun, 10 Nov 2019 14:30:04 +0000 (15:30 +0100)
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
misc-utils/ftl_check.c

index e8549224e0e4dc4ab9b7898405abb1017fc4a599..5a0415538ad8b899ea1351d853716cc981418d39 100644 (file)
@@ -75,7 +75,7 @@ static void check_partition(int fd)
        erase_unit_header_t hdr, hdr2;
        off_t i;
        u_int j, nbam, *bam;
-       int control, data, free, deleted;
+       int control, data, blk_free, deleted;
 
        /* Get partition size, block size */
        if (ioctl(fd, MEMGETINFO, &mtd) != 0) {
@@ -150,10 +150,10 @@ static void check_partition(int fd)
                                perror("read failed");
                                break;
                        }
-                       free = deleted = control = data = 0;
+                       blk_free = deleted = control = data = 0;
                        for (j = 0; j < nbam; j++) {
                                if (BLOCK_FREE(le32_to_cpu(bam[j])))
-                                       free++;
+                                       blk_free++;
                                else if (BLOCK_DELETED(le32_to_cpu(bam[j])))
                                        deleted++;
                                else switch (BLOCK_TYPE(le32_to_cpu(bam[j]))) {
@@ -163,9 +163,11 @@ static void check_partition(int fd)
                                }
                        }
                        printf("  Block allocation: %d control, %d data, %d free,"
-                                       " %d deleted\n", control, data, free, deleted);
+                                       " %d deleted\n", control, data, blk_free, deleted);
                }
        }
+
+       free(bam);
 } /* format_partition */
 
 /* Show usage information */