From a4a760a3cf793857e5fac7d13f5ef7028d30f666 Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Fri, 20 Feb 2015 12:58:20 +0530 Subject: glusterd/snapshot: Fix the ret check in gd_restore_snap_volume In gd_restore_snap_volume(), irrespective of the ret value we were trying to do a list_add_tail to new_volinfo variable. There might be cases where this variable might be NULL, and hence cause a crash. Change-Id: I158c5ae655ea27c9a91be3cb9d95a80a3dd05559 BUG: 1194538 Signed-off-by: Avra Sengupta Reviewed-on: http://review.gluster.org/9719 Reviewed-by: Atin Mukherjee Reviewed-by: Rajesh Joseph Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi Tested-by: Krishnan Parthasarathi --- xlators/mgmt/glusterd/src/glusterd-snapshot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'xlators/mgmt') diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 41559e75ea0..171d071efc3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -8264,12 +8264,13 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict, ret = 0; out: - if (ret && NULL != new_volinfo) { + if (ret) { /* In case of any failure we should free new_volinfo. Doing * this will also remove the entry we added in conf->volumes * if it was added there. */ - (void)glusterd_volinfo_delete (new_volinfo); + if (new_volinfo) + (void)glusterd_volinfo_delete (new_volinfo); } else { list_for_each_entry_safe (voliter, temp_volinfo, &orig_vol->snap_volumes, snapvol_list) { -- cgit