From 98f602cd64e3f8cc7e4c4a7245e132c0afd7347f Mon Sep 17 00:00:00 2001 From: Poornima G Date: Sun, 26 Mar 2017 07:59:53 +0530 Subject: 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. Change-Id: Ie58902d079fdc58416d17b5fa5f61375decb1c99 BUG: 1435943 Signed-off-by: Poornima G Reviewed-on: https://review.gluster.org/16948 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Raghavendra G --- xlators/protocol/client/src/client-rpc-fops.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'xlators') diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index f70511709e1..58eb1c92311 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -2549,6 +2549,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; @@ -2564,7 +2566,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; @@ -2611,6 +2612,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; @@ -2626,7 +2629,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; -- cgit