Whamcloud - gitweb
LU-17000 lnet: remove redundant errno check in liblnetconfig.c 46/51846/3
authorJake McManus <jacobpmcmanus@gmail.com>
Thu, 10 Aug 2023 03:12:03 +0000 (23:12 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 31 Aug 2023 06:34:13 +0000 (06:34 +0000)
commit1db59b7b603a917d4ab1bba98d94dd169475b86b
tree87b68d54d90b0ef6fbdb5f1fc167a3f86718dbff
parent8e53a0ea594a7d7eb9cd7541233bc8771d4023b5
LU-17000 lnet: remove redundant errno check in liblnetconfig.c

Variable root is assigned NULL at the beginning of
lustre_lnet_show_stats(). If l_ioctl() fails, its return value
stored in rc will take the True path in the following conditional.
This conditional currently contains a redundant check for errno,
despite the fact that rc would = -errno in this case. If errno had
changed between the l_ioctl() call and this subsequent read, errno
could be 0, which would, from the out: label, lead to a NULL
root being used as a parameter in cYAML_insert_sibling() and
dereferencing the NULL root pointer.

Replaced l_errno's use as a parameter in strerror with -rc, and
removed decleration and other references to l_errno.

Addresses-Coverity-ID: 397850 ("Explicit null dereferenced")

Signed-off-by: Jake McManus <jacobpmcmanus@gmail.com>
Change-Id: I78f080837b60c8216c52bda8562d4c0f9f45a132
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51846
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c