Whamcloud - gitweb
LU-4849 lfs: Avoid double closedir() on err from cb_mv_init() 05/9905/2
authorSwapnil Pimpale <spimpale@ddn.com>
Mon, 7 Apr 2014 17:19:09 +0000 (13:19 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 6 May 2014 03:16:05 +0000 (03:16 +0000)
In cb_mv_init(), set *dirp to NULL if the parent cannot be opened.
This will avoid a double free when closedir() is called a second
time on the way out of llapi_semantic_traverse()

Signed-off-by: Swapnil Pimpale <spimpale@ddn.com>
Change-Id: I115137f01cd4e370f4ef766028ad9269e85ed10a
Reviewed-on: http://review.whamcloud.com/9905
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/utils/liblustreapi.c

index 65eb0f9..479a445 100644 (file)
@@ -3144,9 +3144,10 @@ static int cb_mv_init(char *path, DIR *parent, DIR **dirp,
        if (parent == NULL) {
                dir = opendir_parent(path);
                if (dir == NULL) {
+                       *dirp = NULL;
                        ret = -errno;
-                       fprintf(stderr, "can not open %s ret %d\n",
-                               path, ret);
+                       llapi_error(LLAPI_MSG_ERROR, ret,
+                                   "can not open %s\n", path);
                        return ret;
                }
        }