From 02a7a9ef1c0703990d6333b8b800a36da04c9f3e Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 17 Apr 2019 08:58:57 +0200 Subject: features/locks: fix coverity issues This patch fixes the following NULL dereferences identified by Coverity: * CID 1398619 * CID 1398621 * CID 1398623 * CID 1398625 * CID 1398626 Change-Id: Id6af0d7cba0bb3346005376bc27180e8476255a4 Updates: bz#789278 Signed-off-by: Xavi Hernandez --- xlators/features/locks/src/common.c | 2 +- xlators/features/locks/src/posix.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'xlators/features/locks/src') diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c index 6e7fb4b2f63..9e06484308e 100644 --- a/xlators/features/locks/src/common.c +++ b/xlators/features/locks/src/common.c @@ -478,7 +478,7 @@ pl_inode_get(xlator_t *this, inode_t *inode, pl_local_t *local) unlock: UNLOCK(&inode->lock); - if (pl_is_mandatory_locking_enabled(pl_inode) && + if ((pl_inode != NULL) && pl_is_mandatory_locking_enabled(pl_inode) && pl_inode->check_mlock_info && local) { /* Note: The lock enforcement information per file can be stored in the attribute flag of stat(x) in posix. With that there won't be a need diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index 3f1c7a733ff..9d7210f1bb5 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -125,6 +125,11 @@ fetch_pathinfo(xlator_t *, inode_t *, int32_t *, char **); (name && (strcmp(name, GF_ENFORCE_MANDATORY_LOCK) == 0))) { \ inode_t *__inode = (loc ? loc->inode : fd->inode); \ pl_inode_t *__pl_inode = pl_inode_get(this, __inode, NULL); \ + if (__pl_inode == NULL) { \ + op_ret = -1; \ + op_errno = ENOMEM; \ + goto unwind; \ + } \ if (!pl_is_mandatory_locking_enabled(__pl_inode) || \ !priv->mlock_enforced) { \ op_ret = -1; \ -- cgit