diff options
author | Karel Zak | 2013-03-27 16:25:30 +0100 |
---|---|---|
committer | Karel Zak | 2013-03-27 16:25:30 +0100 |
commit | 4e6fc1139b42b0051665ea1809baf491087369b1 (patch) | |
tree | 4c5dc215ce55df87aff18d80592b44daefe46faf /misc-utils | |
parent | setterm: fix memory leak [coverity scan] (diff) | |
download | kernel-qcow2-util-linux-4e6fc1139b42b0051665ea1809baf491087369b1.tar.gz kernel-qcow2-util-linux-4e6fc1139b42b0051665ea1809baf491087369b1.tar.xz kernel-qcow2-util-linux-4e6fc1139b42b0051665ea1809baf491087369b1.zip |
wipefs: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/wipefs.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c index 56024301e..156f2143d 100644 --- a/misc-utils/wipefs.c +++ b/misc-utils/wipefs.c @@ -216,7 +216,7 @@ get_desc_for_probe(struct wipe_desc *wp, blkid_probe pr) static blkid_probe new_probe(const char *devname, int mode) { - blkid_probe pr; + blkid_probe pr = NULL; if (!devname) return NULL; @@ -227,8 +227,10 @@ new_probe(const char *devname, int mode) goto error; pr = blkid_new_probe(); - if (pr && blkid_probe_set_device(pr, fd, 0, 0)) + if (pr && blkid_probe_set_device(pr, fd, 0, 0)) { + close(fd); goto error; + } } else pr = blkid_new_probe_from_filename(devname); @@ -245,6 +247,7 @@ new_probe(const char *devname, int mode) return pr; error: + blkid_free_probe(pr); err(EXIT_FAILURE, _("error: %s: probing initialization failed"), devname); return NULL; } |