From 3a5169907b44d79e207c35941b1973b1f60d2079 Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Thu, 24 Nov 2016 18:36:28 +0530 Subject: cluster/afr: Handle rpc errors, xdr failures etc with proper NULL checks Change-Id: Id8ba76ba116d056bc7299dc5ce0980680a5a23f8 BUG: 1398226 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/15924 Reviewed-by: Pranith Kumar Karampuri Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- xlators/cluster/afr/src/afr-transaction.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'xlators') diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index 88ff206a38c..a456c827f4b 100644 --- a/xlators/cluster/afr/src/afr-transaction.c +++ b/xlators/cluster/afr/src/afr-transaction.c @@ -1249,12 +1249,23 @@ afr_pre_op_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->op_errno = op_errno; afr_transaction_fop_failed (frame, this, child_index); } - write_args_cbk = &args_cbk->rsp_list[1]; - afr_inode_write_fill (frame, this, (long) i, write_args_cbk->op_ret, - write_args_cbk->op_errno, - &write_args_cbk->prestat, - &write_args_cbk->poststat, - write_args_cbk->xdata); + + /* If the compound fop failed due to saved_frame_unwind(), then + * protocol/client fails it even before args_cbk is allocated. + * Handle that case by passing the op_ret, op_errno values explicitly. + */ + if ((op_ret == -1) && (args_cbk == NULL)) { + afr_inode_write_fill (frame, this, (long) i, op_ret, op_errno, + NULL, NULL, NULL); + } else { + write_args_cbk = &args_cbk->rsp_list[1]; + afr_inode_write_fill (frame, this, (long) i, + write_args_cbk->op_ret, + write_args_cbk->op_errno, + &write_args_cbk->prestat, + &write_args_cbk->poststat, + write_args_cbk->xdata); + } call_count = afr_frame_return (frame); -- cgit