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