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

[Coverity CID :198865]Null pointer dereferences in /drivers/usb/device/usb_dc_stm32.c #16582

Closed
aasthagr opened this issue Jun 3, 2019 · 1 comment · Fixed by #16633
Closed
Assignees
Labels
area: Drivers bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: medium Medium impact/importance bug

Comments

@aasthagr
Copy link
Collaborator

aasthagr commented Jun 3, 2019

Static code scan issues seen in File: /drivers/usb/device/usb_dc_stm32.c
Category: Null pointer dereferences
Function: HAL_PCD_SetupStageCallback
Component: Drivers
CID: 198865
Please fix or provide comments to square it off in coverity in the link: https://scan9.coverity.com/reports.htm#v32951/p12996

@aasthagr aasthagr added area: Drivers bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix labels Jun 3, 2019
@aasthagr
Copy link
Collaborator Author

aasthagr commented Jun 3, 2019

*** CID 198865:  Null pointer dereferences  (NULL_RETURNS)
/drivers/usb/device/usb_dc_stm32.c: 966 in HAL_PCD_SetupStageCallback()
960     	struct usb_setup_packet *setup = (void *)usb_dc_stm32_state.pcd.Setup;
961     	struct usb_dc_stm32_ep_state *ep_state;
962     
963     	LOG_DBG("");
964     
965     	ep_state = usb_dc_stm32_get_ep_state(EP0_OUT); /* can't fail for ep0 */
>>>     CID 198865:  Null pointer dereferences  (NULL_RETURNS)
>>>     Dereferencing a null pointer "ep_state".
966     	ep_state->read_count = SETUP_SIZE;
967     	ep_state->read_offset = 0U;
968     	memcpy(&usb_dc_stm32_state.ep_buf[EP0_IDX],
969     	       usb_dc_stm32_state.pcd.Setup, ep_state->read_count);
970     
971     	if (ep_state->cb) {

@nashif nashif added the priority: medium Medium impact/importance bug label Jun 4, 2019
finikorg added a commit to finikorg/zephyr that referenced this issue Jun 5, 2019
Fixes coverity issue CID: 198865.

Fixes zephyrproject-rtos#16582

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
carlescufi pushed a commit that referenced this issue Jun 19, 2019
Fixes coverity issue CID: 198865.

Fixes #16582

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Drivers bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants