From: Nathaniel Clark Date: Wed, 16 Jul 2014 15:03:56 +0000 (-0400) Subject: LU-5323 utils: fix memory leak in lfs_hsm_request() X-Git-Tag: 2.6.51~49 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F16%2F11116%2F3;p=fs%2Flustre-release.git LU-5323 utils: fix memory leak in lfs_hsm_request() Fix memory leak in error case in lfs_hsm_request(). hur is allocated, and should be freed befor being overwritten. Cleanup error messages. Signed-off-by: Nathaniel Clark Change-Id: I9c01400fafb53e3914b9ed5eb9c8c9e575423551 Reviewed-on: http://review.whamcloud.com/11116 Tested-by: Jenkins Reviewed-by: Dmitry Eremin Reviewed-by: John L. Hammond Reviewed-by: frank zago Tested-by: Maloo Reviewed-by: Andreas Dilger --- diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 7ca4a7e..3b2ee15 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -3755,7 +3755,7 @@ static int lfs_hsm_request(int argc, char **argv, int action) hur = llapi_hsm_user_request_alloc(nbfile_alloc, opaque_len); if (hur == NULL) { - fprintf(stderr, "Cannot allocate " + fprintf(stderr, "hsm: cannot allocate " "the request: %s\n", strerror(errno)); hur = oldhur; @@ -3765,8 +3765,11 @@ static int lfs_hsm_request(int argc, char **argv, int action) } size = hur_len(oldhur); if (size < 0) { - fprintf(stderr, "Cannot allocate " - "the requested size\n"); + fprintf(stderr, "hsm: cannot allocate " + "%u files + %u bytes data\n", + oldhur->hur_request.hr_itemcount, + oldhur->hur_request.hr_data_len); + free(hur); hur = oldhur; rc = -E2BIG; fclose(fp);