diff options
author | Sheetal Pamecha <sheetal.pamecha08@gmail.com> | 2018-10-01 17:02:09 +0530 |
---|---|---|
committer | Kotresh HR <khiremat@redhat.com> | 2018-10-08 04:58:00 +0000 |
commit | 1d392e2970fb5b1d2f8cf2904e7b7e5d32a21882 (patch) | |
tree | 9adafb87b5a375f68dbfab70519b4020eff2f5ca /xlators/features/bit-rot/src/stub/bit-rot-stub.c | |
parent | 6a6709489525e2c438a3ec1974771247bc2e07d4 (diff) |
features/bit-rot: NULL pointer deferencing clang fix
Problem: local could be NULL
Added condition checks to address this issue
Updates: bz#1622665
Change-Id: I7be7dacc5386a77441385240b43f22d85074b69d
Signed-off-by: Sheetal Pamecha <sheetal.pamecha08@gmail.com>
Diffstat (limited to 'xlators/features/bit-rot/src/stub/bit-rot-stub.c')
-rw-r--r-- | xlators/features/bit-rot/src/stub/bit-rot-stub.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c index 2f5cc2b..c6c9b6aa 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c @@ -1588,6 +1588,11 @@ br_stub_getxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, local = frame->local; frame->local = NULL; + if (!local) { + op_ret = -1; + op_errno = EINVAL; + goto unwind; + } inode = local->u.context.inode; op_ret = -1; @@ -1654,10 +1659,8 @@ delkeys: unwind: STACK_UNWIND_STRICT(getxattr, frame, op_ret, op_errno, xattr, xdata); - if (local) { - br_stub_cleanup_local(local); - br_stub_dealloc_local(local); - } + br_stub_cleanup_local(local); + br_stub_dealloc_local(local); return 0; } @@ -3086,6 +3089,11 @@ br_stub_unlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) goto unwind; + if (!local) { + gf_msg(this->name, GF_LOG_WARNING, 0, BRS_MSG_NULL_LOCAL, + "local is NULL"); + goto unwind; + } inode = local->u.context.inode; if (!IA_ISREG(inode->ia_type)) goto unwind; |