Blob Blame History Raw
From 29e1b9171bfab7802d40268e75a2af6eeb186c97 Mon Sep 17 00:00:00 2001
From: Poornima G <pgurusid@redhat.com>
Date: Sun, 26 Mar 2017 07:59:53 +0530
Subject: [PATCH 371/375] protocol-client: Initialize the list_head before
 using

In client3_3_readdir(p)_cbk, in case of error conditions,
it is possible that the list_head is used before initializing.
Hence move the initialization before usage.

> Reviewed-on: https://review.gluster.org/16948
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
> Signed-off-by: Poornima G <pgurusid@redhat.com>

Change-Id: Ie58902d079fdc58416d17b5fa5f61375decb1c99
BUG: 1427096
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/102518
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/protocol/client/src/client-rpc-fops.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c
index 2eda19c..116a11a 100644
--- a/xlators/protocol/client/src/client-rpc-fops.c
+++ b/xlators/protocol/client/src/client-rpc-fops.c
@@ -2559,6 +2559,8 @@ client3_3_readdir_cbk (struct rpc_req *req, struct iovec *iov, int count,
         frame = myframe;
         local = frame->local;
 
+        INIT_LIST_HEAD (&entries.list);
+
         if (-1 == req->rpc_status) {
                 rsp.op_ret   = -1;
                 rsp.op_errno = ENOTCONN;
@@ -2574,7 +2576,6 @@ client3_3_readdir_cbk (struct rpc_req *req, struct iovec *iov, int count,
                 goto out;
         }
 
-        INIT_LIST_HEAD (&entries.list);
         ret = client_post_readdir (this, &rsp, &entries, &xdata);
         if (ret < 0)
                 goto out;
@@ -2621,6 +2622,8 @@ client3_3_readdirp_cbk (struct rpc_req *req, struct iovec *iov, int count,
         frame = myframe;
         local = frame->local;
 
+        INIT_LIST_HEAD (&entries.list);
+
         if (-1 == req->rpc_status) {
                 rsp.op_ret   = -1;
                 rsp.op_errno = ENOTCONN;
@@ -2636,7 +2639,6 @@ client3_3_readdirp_cbk (struct rpc_req *req, struct iovec *iov, int count,
                 goto out;
         }
 
-        INIT_LIST_HEAD (&entries.list);
         ret = client_post_readdirp (this, &rsp, local->fd, &entries, &xdata);
         if (ret < 0)
                 goto out;
-- 
1.8.3.1