]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
[v3, 1/2] xfsprogs: fix potential memory leak in verify_set_primary_sb()
authorLi Zhong <zhong@linux.vnet.ibm.com>
Thu, 26 Sep 2013 06:45:32 +0000 (06:45 +0000)
committerRich Johnston <rjohnston@sgi.com>
Thu, 17 Oct 2013 18:54:02 +0000 (13:54 -0500)
commit548c2e3e5b123266b4b89cc81bedd113442570b8
treedd24b0979426e5c7868faad309338842ff43254d
parent70ee4153f4c998774adcee1e576d3c1f305b92d0
[v3, 1/2] xfsprogs: fix potential memory leak in verify_set_primary_sb()

If verify_set_primary_sb() completes the secondary sb scanning loop with
too few valid secondaries found (num_ok < num_sbs / 2), it will immediately
return without freeing any of the previously allocated memory (variables
sb, checked, and any items on the geo list).  This was reported by
the Coverity scanner as CID 997012, 997013 and 997014.

Fix this by using the out_free_list: goto target for this error case.

Earlier, if get_sb() fails in the secondary scan loop, it goes to
the out: target which does not free any items on the geo list.   Fix
this by using the out_free_list: target as well, and remove the now-unused
out: target.

Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
repair/sb.c