Whamcloud - gitweb
LU-5323 utils: fix memory leak in lfs_hsm_request() 16/11116/3
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Wed, 16 Jul 2014 15:03:56 +0000 (11:03 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 1 Aug 2014 03:50:04 +0000 (03:50 +0000)
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 <nathaniel.l.clark@intel.com>
Change-Id: I9c01400fafb53e3914b9ed5eb9c8c9e575423551
Reviewed-on: http://review.whamcloud.com/11116
Tested-by: Jenkins
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: frank zago <fzago@cray.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/utils/lfs.c

index 7ca4a7e..3b2ee15 100644 (file)
@@ -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) {
                                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;
                                                "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) {
                                }
                                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);
                                        hur = oldhur;
                                        rc = -E2BIG;
                                        fclose(fp);