From 9a526c4faff0f96b2025dde252e3a622c1d6d188 Mon Sep 17 00:00:00 2001 From: Mohammed Azhar Padariyakam Date: Mon, 6 Nov 2017 15:14:24 +0530 Subject: xlators/client-rpc-fops: Fix Coverity Issues Coverity Id: 803, 804 from [1] Problem: USE_AFTER_FREE code at client3_3_lookup: 3371 USE_AFTER_FREE at client3_3_readdir: 5562 Solution: Postponed iobuf_unref(rsp_iobuf) to a location after all dereferences of rsp_iobuf [1]:https://download.gluster.org/pub/gluster/glusterfs/static-analysis/master/glusterfs-coverity/2017-10-30-9aa574a5/html/ Change-Id: I34f90d72b1248e5526ff1d2b3273cdab619cf4f8 BUG: 789278 Signed-off-by: Mohammed Azhar Padariyakam --- xlators/protocol/client/src/client-rpc-fops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xlators/protocol/client') diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index 0561def3aab..2026a2b1c80 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -3368,12 +3368,12 @@ client3_3_lookup (call_frame_t *frame, xlator_t *this, } iobref_add (rsp_iobref, rsp_iobuf); - iobuf_unref (rsp_iobuf); rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr (rsp_iobuf); rsphdr->iov_len = iobuf_pagesize (rsp_iobuf); count = 1; local->iobref = rsp_iobref; + iobuf_unref (rsp_iobuf); rsp_iobuf = NULL; rsp_iobref = NULL; } @@ -5559,13 +5559,13 @@ client3_3_readdir (call_frame_t *frame, xlator_t *this, } iobref_add (rsp_iobref, rsp_iobuf); - iobuf_unref (rsp_iobuf); rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr (rsp_iobuf); rsphdr->iov_len = iobuf_pagesize (rsp_iobuf); count = 1; local->iobref = rsp_iobref; + iobuf_unref (rsp_iobuf); rsp_iobuf = NULL; rsp_iobref = NULL; } -- cgit