diff options
author | Richard Yao <[email protected]> | 2014-04-22 23:35:38 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2014-05-30 17:00:37 -0700 |
commit | 4def05f8a68f7255dfb88606a9b475314c828a06 (patch) | |
tree | 4ea217d5c117460b1c242a7b49373c9f8e2b6713 | |
parent | 62a05896e8a438a980912236bc2b00fcce71c015 (diff) |
Fix memory leak in zpool_clear_label()
Clang's static analyzer reported a memory leak in zpool_clear_label().
Upon review, it turns out to be right. This should be a very short lived
leak because no daemons use this functionality, but that does not
preclude the possibility of third party daemons that do use it. Lets fix
it to be a good Samaritan.
Signed-off-by: Richard Yao <[email protected]>
Signed-off-by: Ned Bass <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #2330
-rw-r--r-- | lib/libzfs/libzfs_import.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index b5a079c0e..8afe77af3 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -922,8 +922,10 @@ zpool_clear_label(int fd) for (l = 0; l < VDEV_LABELS; l++) { if (pwrite64(fd, label, sizeof (vdev_label_t), - label_offset(size, l)) != sizeof (vdev_label_t)) + label_offset(size, l)) != sizeof (vdev_label_t)) { + free(label); return (-1); + } } free(label); |