Fix memory leaks found by clang's static analyzer
Subsystems (2)
PATCH 1/1 Fix memory leaks found by clang's static analyzer
Signed-off-by Daniel van Gerpen <[email protected]>
--- ftl_format.c | 4 ++++ lib/libmtd.c | 1 + mkfs.ubifs/devtable.c | 12 ++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-)
ftl_format.c +4 -0
@@ -190,6 +190,7 @@ static int format_partition(int fd, int quiet, int interrogate,fflush (stdout); }perror ("block erase failed" ); +free (bam);return -1 ; } erase.start += erase.length;
@@ -245,6 +246,9 @@ static int format_partition(int fd, int quiet, int interrogate,break ; } } + +free (bam); +if (i <le16_to_cpu (hdr.NumEraseUnits))return -1 ;else
lib/libmtd.c +1 -0
@@ -1113,6 +1113,7 @@ static int legacy_auto_oob_layout(const struct mtd_dev_info *mtd, int fd,memcpy (oob + start, tmp_buf + start, len); } +free (tmp_buf);return 0 ; }
mkfs.ubifs/devtable.c +8 -4
@@ -213,8 +213,10 @@ static int interpret_table_entry(const char *line) } } -if (increment !=0 && count ==0 ) -return err_msg ("count cannot be zero if increment is non-zero" ); +if (increment !=0 && count ==0 ) { +err_msg ("count cannot be zero if increment is non-zero" ); + goto out_free; + }/* * Add the file/directory/device node (last component of the path) to
@@ -239,8 +241,10 @@ static int interpret_table_entry(const char *line)dbg_msg (3 ,"inserting '%s' into name hash table (major %d, minor %d)" , name,major (nh_elt->dev),minor (nh_elt->dev)); -if (hashtable_search (ph_elt->name_htbl, name)) -return err_msg ("'%s' is referred twice" , buf); +if (hashtable_search (ph_elt->name_htbl, name)) { +err_msg ("'%s' is referred twice" , buf); + goto out_free; + } nh_elt->name = name;if (!hashtable_insert (ph_elt->name_htbl, name, nh_elt)) {
Signature · 1 line
1.8.3.2