Skip to content
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

Open
wants to merge 1 commit into
base: v2.4.115
Choose a base branch
from

Conversation

Sapna1-singh
Copy link

Below are the issues fixed:

  • Buffer not null terminated
  • Resource leak

Tracked-On: OAM-122340

intel/intel_bufmgr_fake.c Outdated Show resolved Hide resolved
intel/intel_bufmgr_gem.c Outdated Show resolved Hide resolved
intel/intel_decode.c Show resolved Hide resolved
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));

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';
    }

Copy link

@akodanka akodanka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -976,7 +982,8 @@ has_userptr(drm_intel_bufmgr_gem *bufmgr_gem)

pgsz = sysconf(_SC_PAGESIZE);
assert(pgsz > 0);

if (pgsz < 0)
return false;

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

@@ -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();

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;

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;

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

if (!gen)
return NULL;
// LOGICALLY_DEAD_CODE: As the value of gen can't be 0.
//if (!gen)

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]>
@feijiang1
Copy link

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.

@sysopenci sysopenci added the Stale Stale label for inactive open prs label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Stale label for inactive open prs Valid commit message
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants