From 09baa5d7fb91d1f50976807f1da0f7bbf177fa00 Mon Sep 17 00:00:00 2001 From: Ashish Pandey Date: Thu, 11 Oct 2018 12:12:38 +0530 Subject: features/locks: Fix Coverity issues CID: 1395812 Explicit null dereferenced 1356542 Dereference null return value https://scan6.coverity.com/reports.htm#v42607/p10714/fileInstanceId=86261835&defectInstanceId=26407100&mergedDefectId=1395812 https://scan6.coverity.com/reports.htm#v42607/p10714/fileInstanceId=86261835&defectInstanceId=26407215&mergedDefectId=1356542 Change-Id: I2c20972a8080fa7a70b88eab0688b9cf734bbf24 updates: bz#789278 Signed-off-by: Ashish Pandey --- xlators/features/locks/src/posix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'xlators/features') diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index 3528e686a96..f08a22d4fc3 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -755,8 +755,8 @@ truncate_stat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, gf_boolean_t can_block = _gf_true; int allowed = 1; - GF_VALIDATE_OR_GOTO("locks", this, unwind); local = frame->local; + GF_VALIDATE_OR_GOTO("locks", this, unwind); if (op_ret != 0) { gf_log(this->name, GF_LOG_ERROR, @@ -854,6 +854,7 @@ unwind: "truncate failed with " "ret: %d, error: %s", op_ret, strerror(op_errno)); + if (local->op == GF_FOP_TRUNCATE) loc_wipe(&local->loc[0]); if (local->xdata) @@ -2488,6 +2489,8 @@ pl_forget(xlator_t *this, inode_t *inode) INIT_LIST_HEAD(&entrylks_released); pl_inode = pl_inode_get(this, inode); + if (!pl_inode) + return 0; pthread_mutex_lock(&pl_inode->mutex); { -- cgit