From ee3661b312734434c529fb85462316ef0d197c4e Mon Sep 17 00:00:00 2001 From: Swapnil Pimpale Date: Mon, 7 Apr 2014 13:19:09 -0400 Subject: [PATCH] LU-4849 lfs: Avoid double closedir() on err from cb_mv_init() 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 Change-Id: I115137f01cd4e370f4ef766028ad9269e85ed10a Reviewed-on: http://review.whamcloud.com/9905 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: John L. Hammond --- lustre/utils/liblustreapi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 65eb0f9..479a445 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -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; } } -- 1.8.3.1