50dc83
From 4a72ac20f728aa5c3141359ff89f1b61d4cd210a Mon Sep 17 00:00:00 2001
50dc83
From: Mohammed Rafi KC <rkavunga@redhat.com>
50dc83
Date: Fri, 17 May 2019 23:03:35 +0530
50dc83
Subject: [PATCH 157/169] afr/frame: Destroy frame after
50dc83
 afr_selfheal_entry_granular
50dc83
50dc83
In function "afr_selfheal_entry_granular", after completing the
50dc83
heal we are not destroying the frame. This will lead to crash.
50dc83
when we execute statedump operation, where it tried to access
50dc83
xlator object. If this xlator object is freed as part of the
50dc83
graph destroy this will lead to an invalid memory access
50dc83
50dc83
Upstream patch:https://review.gluster.org/22743
50dc83
50dc83
>Change-Id: I0a5e78e704ef257c3ac0087eab2c310e78fbe36d
50dc83
>fixes: bz#1708926
50dc83
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
50dc83
50dc83
Change-Id: I326354008e6d98376c8333d270f2f80036ad07f0
50dc83
BUG: 1716626
50dc83
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
50dc83
Reviewed-on: https://code.engineering.redhat.com/gerrit/172282
50dc83
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
50dc83
Tested-by: RHGS Build Bot <nigelb@redhat.com>
50dc83
---
50dc83
 xlators/cluster/afr/src/afr-self-heal-entry.c | 11 ++++++++---
50dc83
 1 file changed, 8 insertions(+), 3 deletions(-)
50dc83
50dc83
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c
50dc83
index fc09b4c..a6890fa 100644
50dc83
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
50dc83
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
50dc83
@@ -832,6 +832,8 @@ afr_selfheal_entry_granular(call_frame_t *frame, xlator_t *this, fd_t *fd,
50dc83
     subvol = priv->children[subvol_idx];
50dc83
 
50dc83
     args.frame = afr_copy_frame(frame);
50dc83
+    if (!args.frame)
50dc83
+        goto out;
50dc83
     args.xl = this;
50dc83
     /* args.heal_fd represents the fd associated with the original directory
50dc83
      * on which entry heal is being attempted.
50dc83
@@ -850,9 +852,10 @@ afr_selfheal_entry_granular(call_frame_t *frame, xlator_t *this, fd_t *fd,
50dc83
          * do not treat heal as failure.
50dc83
          */
50dc83
         if (is_src)
50dc83
-            return -errno;
50dc83
+            ret = -errno;
50dc83
         else
50dc83
-            return 0;
50dc83
+            ret = 0;
50dc83
+        goto out;
50dc83
     }
50dc83
 
50dc83
     ret = syncop_dir_scan(subvol, &loc, GF_CLIENT_PID_SELF_HEALD, &args,
50dc83
@@ -862,7 +865,9 @@ afr_selfheal_entry_granular(call_frame_t *frame, xlator_t *this, fd_t *fd,
50dc83
 
50dc83
     if (args.mismatch == _gf_true)
50dc83
         ret = -1;
50dc83
-
50dc83
+out:
50dc83
+    if (args.frame)
50dc83
+        AFR_STACK_DESTROY(args.frame);
50dc83
     return ret;
50dc83
 }
50dc83
 
50dc83
-- 
50dc83
1.8.3.1
50dc83