Skip to content

Commit

Permalink
Fix memory leak in zpool_clear_label()
Browse files Browse the repository at this point in the history
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 openzfs#2330
  • Loading branch information
ryao authored and behlendorf committed May 31, 2014
1 parent 62a0589 commit 4def05f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/libzfs/libzfs_import.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4def05f

Please sign in to comment.