-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for static analysis issues #35
base: v2.4.115
Are you sure you want to change the base?
Conversation
f8898d2
to
3b98e1f
Compare
libsync.h
Outdated
@@ -91,6 +91,11 @@ static inline int sync_merge(const char *name, int fd1, int fd2) | |||
data.fd2 = fd2; | |||
strncpy(data.name, name, sizeof(data.name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the copy be guarded against the length of name like this:
if (sizeof(data.name) < strlen(name)) {
strncpy(data.name, name, sizeof(data.name));
data.name[sizeof(data.name) - 1] = '\0';
} else {
strncpy(data.name, name, strlen(name) - 1);
data.name[strlen(name)] = '\0';
}
3b98e1f
to
f6d5edf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
intel/intel_bufmgr_gem.c
Outdated
@@ -976,7 +982,8 @@ has_userptr(drm_intel_bufmgr_gem *bufmgr_gem) | |||
|
|||
pgsz = sysconf(_SC_PAGESIZE); | |||
assert(pgsz > 0); | |||
|
|||
if (pgsz < 0) | |||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add indentation space before return false
intel/intel_decode.c
Outdated
@@ -1114,7 +1114,8 @@ decode_compare_func(uint32_t op) | |||
case 7: | |||
return "gequal"; | |||
} | |||
return ""; | |||
// Adding an assertion to indicate that this point should never be reached. | |||
__builtin_unreachable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check for indentation
xf86drm.c
Outdated
@@ -940,7 +944,8 @@ static int drmOpenDevice(dev_t dev, int minor, int type) | |||
mknod(buf, S_IFCHR | devmode, dev); | |||
if (drm_server_info && drm_server_info->get_perms) { | |||
chown_check_return(buf, user, group); | |||
chmod(buf, devmode); | |||
if (chmod(buf, devmode) != 0) | |||
return errno; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add space before return errno
xf86drm.c
Outdated
@@ -896,7 +899,8 @@ static int drmOpenDevice(dev_t dev, int minor, int type) | |||
if (drm_server_info && drm_server_info->get_perms) { | |||
group = ((int)serv_group >= 0) ? serv_group : DRM_DEV_GID; | |||
chown_check_return(buf, user, group); | |||
chmod(buf, devmode); | |||
if (chmod(buf, devmode) != 0) | |||
return errno; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add space before return errno
intel/intel_decode.c
Outdated
if (!gen) | ||
return NULL; | ||
// LOGICALLY_DEAD_CODE: As the value of gen can't be 0. | ||
//if (!gen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove these lines
Below are the issues fixed: - Buffer not null terminated - Resource leak - Logically dead code - Argument cannot be negative - Dead default in switch - Dereference after null check - Unchecked return value - Data race condition - Unchecked return value from library Tracked-On: OAM-122340 Signed-off-by: Sapna <[email protected]>
f6d5edf
to
e9f3e86
Compare
These coverity issues are related upstream code, then we can directly get waiver for them, don't need fix actually. If we need fix them, it is better directly submit to upstream repo. |
Below are the issues fixed:
Tracked-On: OAM-122340