Skip to content

[Coverity CID: 529867] Overflowed return value in kernel/sched.c #92601

@zephyrbot

Description

@zephyrbot

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/fd6b05c81b86a1ffe465d56ded7b73a9fdb7f14b/kernel/sched.c#L1

Category: Insecure data handling
Function: z_tick_sleep
Component: Kernel
CID: 529867

Details:

return ticks;

1110     	uint32_t left_ticks = expected_wakeup_ticks - sys_clock_tick_get_32();
1111     
1112     	/* To handle a negative value correctly, once type-cast it to signed 32 bit */
1113     	k_ticks_t ticks = (k_ticks_t)(int32_t)left_ticks;
1114     
1115     	if (ticks > 0) {
>>>     CID 529867:         Insecure data handling  (INTEGER_OVERFLOW)
>>>     "ticks", which might have underflowed, is returned from the function.
1116     		return ticks;
1117     	}
1118     
1119     	return 0;
1120     }
1121     

For more information about the violation, check the Coverity Reference. (CWE-190)

Please fix or provide comments in coverity using the link:

https://scan9.scan.coverity.com/#/project-view/29271/12996?selectedIssue=529867

Note: This issue was created automatically. Priority was set based on classification
of the file affected and the impact field in coverity. Assignees were set using the MAINTAINERS file.

Also see the related Coverity documentation for more information.

Metadata

Metadata

Labels

CoverityA Coverity detected issue or its fixarea: KernelbugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions