Message ID | 1378348738-14451-3-git-send-email-guihc.fnst@cn.fujitsu.com (mailing list archive) |
---|---|
State | Under Review, archived |
Headers | show |
On Thu, Sep 05, 2013 at 10:38:55AM +0800, Gui Hecheng wrote: > The local probe variable in is_ssd() freed upon unsuccessful return; FYI, I've applied a patch from Wang Shilong "Btrfs-progs: fix compile warning in is_ssd()" instead of the hunk below and will remove the respective changelog line. The rest of your patch stays. > @@ -1161,8 +1169,10 @@ static int is_ssd(const char *file) > > /* Device number of this disk (possibly a partition) */ > devno = blkid_probe_get_devno(probe); > - if (!devno) > + if (!devno) { > + blkid_free_probe(probe); > return 0; > + } > > /* Get whole disk name (not full path) for this devno */ > blkid_devno_to_wholedisk(devno, wholedisk, sizeof(wholedisk), NULL); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, Sep 09, 2013 at 04:18:55PM +0200, David Sterba wrote: > On Thu, Sep 05, 2013 at 10:38:55AM +0800, Gui Hecheng wrote: > > The local probe variable in is_ssd() freed upon unsuccessful return; > > FYI, I've applied a patch from Wang Shilong "Btrfs-progs: fix compile > warning in is_ssd()" instead of the hunk below and will remove the > respective changelog line. The rest of your patch stays. Scratch that, the changes are not identical. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/mkfs.c b/mkfs.c index 1701783..415889e 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1024,6 +1024,8 @@ static int make_image(char *source_dir, struct btrfs_root *root, int out_fd) struct directory_name_entry dir_head; + struct directory_name_entry *dir_entry = NULL; + ret = lstat(source_dir, &root_st); if (ret) { fprintf(stderr, "unable to lstat the %s\n", source_dir); @@ -1043,6 +1045,12 @@ static int make_image(char *source_dir, struct btrfs_root *root, int out_fd) printf("Making image is completed.\n"); return 0; fail: + while (!list_empty(&dir_head.list)) { + dir_entry = list_entry(dir_head.list.next, + struct directory_name_entry, list); + list_del(&dir_entry->list); + free(dir_entry); + } fprintf(stderr, "Making image is aborted.\n"); return -1; } @@ -1161,8 +1169,10 @@ static int is_ssd(const char *file) /* Device number of this disk (possibly a partition) */ devno = blkid_probe_get_devno(probe); - if (!devno) + if (!devno) { + blkid_free_probe(probe); return 0; + } /* Get whole disk name (not full path) for this devno */ blkid_devno_to_wholedisk(devno, wholedisk, sizeof(wholedisk), NULL);
The local probe variable in is_ssd() freed upon unsuccessful return; The local dir_head list in make_image() freed upon unsuccessful return. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> --- mkfs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)