diff options
author | mohit84 <moagrawa@redhat.com> | 2021-04-22 18:56:28 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-22 18:56:28 +0530 |
commit | 5cbf5d94c719d1c7674a59c8009660197fc56af2 (patch) | |
tree | 3b1da66b522712b6602a3bca4d83fcd324daf9a7 /xlators/features/locks/src/posix.c | |
parent | 7feaeeabd3ad0b1410e78f584b7c5bbfb41ae0e6 (diff) | |
download | glusterfs-release-9.tar.gz glusterfs-release-9.tar.xz glusterfs-release-9.zip |
core: Avoid several dict OR key is NULL message in brick logs (#2344)release-9
Problem: dict_get_with_ref throw a message "dict or key is NULL"
if dict or key is NULL.
Solution: Before access a key check if dictionary is valid.
> Fixes: #1909
> Change-Id: I50911679142b52f854baf20c187962a2a3698f2d
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
> Cherry picked from commit de1b26d68e31b029a59e59a47b51a7e3e6fbfe22
> Reviewed on upstream link https://github.com/gluster/glusterfs/pull/1910
Fixes: #1909
Change-Id: I50911679142b52f854baf20c187962a2a3698f2d
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Diffstat (limited to 'xlators/features/locks/src/posix.c')
-rw-r--r-- | xlators/features/locks/src/posix.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index 9601a8728c..79003b7c16 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -2577,18 +2577,21 @@ pl_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, posix_locks_private_t *priv = this->private; pl_local_t *local = NULL; short lock_type = 0; + int ret = 0; - int ret = dict_get_uint32(xdata, GF_LOCK_MODE, &lk_flags); - if (ret == 0) { - if (priv->mandatory_mode == MLK_NONE) - gf_log(this->name, GF_LOG_DEBUG, - "Lock flags received " - "in a non-mandatory locking environment, " - "continuing"); - else - gf_log(this->name, GF_LOG_DEBUG, - "Lock flags received, " - "continuing"); + if (xdata) { + ret = dict_get_uint32(xdata, GF_LOCK_MODE, &lk_flags); + if (ret == 0) { + if (priv->mandatory_mode == MLK_NONE) + gf_log(this->name, GF_LOG_DEBUG, + "Lock flags received " + "in a non-mandatory locking environment, " + "continuing"); + else + gf_log(this->name, GF_LOG_DEBUG, + "Lock flags received, " + "continuing"); + } } if ((flock->l_start < 0) || ((flock->l_start + flock->l_len) < 0)) { |