d2787b
From 015e6cac71b0a0c330f1e4792f9d60214b191f45 Mon Sep 17 00:00:00 2001
d2787b
From: karthik-us <ksubrahm@redhat.com>
d2787b
Date: Thu, 7 Oct 2021 21:07:46 +0530
d2787b
Subject: [PATCH 603/610] Coverity: Resource leak fix (CID: 1356547)
d2787b
d2787b
Issue:
d2787b
In function gf_svc_readdirp() there is a chance that 'local' will be allocated
d2787b
memory but not released in the failure path.
d2787b
d2787b
Fix:
d2787b
Assign 'local' to 'frame->local' immediately after the successful allocation, so
d2787b
it will be released by the existing failure path code itself.
d2787b
d2787b
> Upstream patch: https://github.com/gluster/glusterfs/pull/2362/
d2787b
> Change-Id: I4474dc4d4be5432d169cb7d434728f211054997e
d2787b
> Signed-off-by: karthik-us <ksubrahm@redhat.com>
d2787b
> Updates: gluster#1060
d2787b
d2787b
BUG: 1997447
d2787b
Change-Id: I4474dc4d4be5432d169cb7d434728f211054997e
d2787b
Signed-off-by: karthik-us <ksubrahm@redhat.com>
d2787b
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/280100
d2787b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d2787b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d2787b
---
d2787b
 xlators/features/snapview-client/src/snapview-client.c | 2 +-
d2787b
 1 file changed, 1 insertion(+), 1 deletion(-)
d2787b
d2787b
diff --git a/xlators/features/snapview-client/src/snapview-client.c b/xlators/features/snapview-client/src/snapview-client.c
d2787b
index 9c789ae..e97db89 100644
d2787b
--- a/xlators/features/snapview-client/src/snapview-client.c
d2787b
+++ b/xlators/features/snapview-client/src/snapview-client.c
d2787b
@@ -2156,6 +2156,7 @@ gf_svc_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
d2787b
                "failed to allocate local");
d2787b
         goto out;
d2787b
     }
d2787b
+    frame->local = local;
d2787b
 
d2787b
     /*
d2787b
      * This is mainly for samba shares (or windows clients). As part of
d2787b
@@ -2184,7 +2185,6 @@ gf_svc_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
d2787b
 
d2787b
     local->subvolume = subvolume;
d2787b
     local->fd = fd_ref(fd);
d2787b
-    frame->local = local;
d2787b
 
d2787b
     STACK_WIND(frame, gf_svc_readdirp_cbk, subvolume, subvolume->fops->readdirp,
d2787b
                fd, size, off, xdata);
d2787b
-- 
d2787b
1.8.3.1
d2787b