From 82a5e6cdacd9310f04830c47fd22e0aa9b7b7251 Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Thu, 23 Jun 2016 12:20:03 +0530 Subject: gfapi : check the value "iovec" in glfs_io_async_cbk only for read The glfs_io_async_cbk() is called from the cbk of all the async ops such as write, read, fsync, ftruncate. In all other cases, expect for read the value for "iovec" is NULL. From the code, glfs_io_async_cbk checks the value in common routine which may end up in failures. Thanks Joe Julian for finding issue and suggesting the fix. Cherry picked from commit 61d72b3d91f2655b04de4ef29262f738a8cf7369: > Change-Id: I0be0123da68f9d8fbb5d94ede2d45566a9add6a5 > BUG: 1349276 > Signed-off-by: Jiffin Tony Thottan > Reported-by: Joe Julian > Reviewed-on: http://review.gluster.org/14779 > Reviewed-by: Niels de Vos > Smoke: Gluster Build System > Tested-by: Kaleb KEITHLEY > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System > Reviewed-by: Joe Julian Change-Id: I0be0123da68f9d8fbb5d94ede2d45566a9add6a5 BUG: 1350880 Reported-by: Joe Julian Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/14822 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Kaleb KEITHLEY CentOS-regression: Gluster Build System Reviewed-by: jiffin tony Thottan --- api/src/glfs-fops.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index ff7f4570b5a..13815f7237b 100644 --- a/api/src/glfs-fops.c +++ b/api/src/glfs-fops.c @@ -742,7 +742,6 @@ glfs_io_async_cbk (int op_ret, int op_errno, call_frame_t *frame, GF_VALIDATE_OR_GOTO ("gfapi", frame, inval); GF_VALIDATE_OR_GOTO ("gfapi", cookie, inval); - GF_VALIDATE_OR_GOTO ("gfapi", iovec, inval); gio = frame->local; frame->local = NULL; @@ -756,6 +755,12 @@ glfs_io_async_cbk (int op_ret, int op_errno, call_frame_t *frame, if (op_ret <= 0) { goto out; } else if (gio->op == GF_FOP_READ) { + if (!iovec) { + op_ret = -1; + op_errno = EINVAL; + goto out; + } + op_ret = iov_copy (gio->iov, gio->count, iovec, count); glfd->offset = gio->offset + op_ret; } else if (gio->op == GF_FOP_WRITE) { -- cgit