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: 236085] Dereference after null check in samples/userspace/prod_consumer/src/app_a.c #35342

Closed
zephyrbot opened this issue May 17, 2021 · 1 comment
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug

Comments

@zephyrbot
Copy link
Collaborator

Static code scan issues found in file:

https:/zephyrproject-rtos/zephyr/tree/21d1ad3762302b3e461953df59430c77e0709274/samples/userspace/prod_consumer/src/app_a.c#L222

Category: Null pointer dereferences
Function: app_a_entry
Component: Samples
CID: 236085

Details:

sample_driver_set_callback(sample_device, sample_callback, NULL);

216      k_thread_heap_assign(k_current_get(), &app_a_resource_pool);
217     
218      /* Set the callback function for the sample driver. This has to be
219       * done from supervisor mode, as this code will run in supervisor
220       * mode in IRQ context.
221       */
>>>     CID 236085:  Null pointer dereferences  (FORWARD_NULL)
>>>     Passing null pointer "sample_device" to "sample_driver_set_callback", which dereferences it.
222      sample_driver_set_callback(sample_device, sample_callback, NULL);
223     
224      /* Set up the writeback thread, which takes processed data from
225       * application B and sends it to the sample device.
226       *
227       * This child thread automatically inherits the memory domain of

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v29271/p12996

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 CODEOWNERS file.

@zephyrbot zephyrbot added bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug labels May 17, 2021
@nashif nashif removed their assignment May 17, 2021
@dcpleung
Copy link
Member

There is a call to k_oops() above if sample_device == NULL, so it won't be NULL when passed to sample_driver_set_callback(). So ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

3 participants