From 3e7c3b25129df098511970c79faf561be08ef87b Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Sat, 12 Jul 2014 22:31:45 +0530 Subject: rpc,glusterd: Set ret to 0 after call to rpc_clnt_submit() This is to guard against a double STACK_DESTROY in the event that rpc_clnt_submit() failed and returned -1 anytime after sending the request over the wire. in which case the stack could be destroyed twice: once in the callback function of the request and once in the error codepath of some of the callers of glusterd_submit_request(). This bug was introduced in http://review.gluster.org/#/c/8257/ Change-Id: I18a345db6eafc62ba312743201ced7d3f8697622 BUG: 1116243 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/8301 Reviewed-by: Harshavardhana Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-utils.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'xlators/mgmt/glusterd') diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 06283884357..14d98c544aa 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -264,9 +264,16 @@ glusterd_submit_request_unlocked (struct rpc_clnt *rpc, void *req, } /* Send the msg */ - ret = rpc_clnt_submit (rpc, prog, procnum, cbkfn, - &iov, count, - NULL, 0, iobref, frame, NULL, 0, NULL, 0, NULL); + rpc_clnt_submit (rpc, prog, procnum, cbkfn, &iov, count, NULL, 0, + iobref, frame, NULL, 0, NULL, 0, NULL); + + /* Unconditionally set ret to 0 here. This is to guard against a double + * STACK_DESTROY in case of a failure in rpc_clnt_submit AFTER the + * request is sent over the wire: once in the callback function of the + * request and once in the error codepath of some of the callers of + * glusterd_submit_request(). + */ + ret = 0; out: if (new_iobref) { iobref_unref (iobref); -- cgit