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 :207989] Dereference after null check in drivers/sensor/sensor_shell.c #22429

Closed
zephyrbot opened this issue Feb 3, 2020 · 0 comments · Fixed by #23380
Closed
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://github.com/zephyrproject-rtos/zephyr/tree/a3e89e84a801d9bc048b0ee2177f0fb11d1a925a/drivers/sensor/sensor_shell.c#L108

Category: Null pointer dereferences
Function: cmd_get_sensor
Component: Drivers
CID: 207989

Details:

102    
103         dev = device_get_binding(argv[1]);
104         if (dev == NULL) {
105             shell_error(shell, "Device unknown (%s)", argv[1]);
106         }
107    
>>>     CID 207989:  Null pointer dereferences  (FORWARD_NULL)
>>>     Passing null pointer "dev" to "sensor_sample_fetch", which dereferences it.
108         err = sensor_sample_fetch(dev);
109         if (err < 0) {
110             shell_error(shell, "Failed to read sensor");
111         }
112    
113         if (argc == 2) {

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v32951/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 Feb 3, 2020
@nashif nashif assigned nashif and unassigned MaureenHelm Feb 3, 2020
nashif added a commit to nashif/zephyr that referenced this issue Mar 10, 2020
If we can't bind to a device, return -ENODEV and do not continue.

Fixes zephyrproject-rtos#22429
Coverity-ID: 207989

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
nashif added a commit that referenced this issue Mar 10, 2020
If we can't bind to a device, return -ENODEV and do not continue.

Fixes #22429
Coverity-ID: 207989

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
hakehuang pushed a commit to hakehuang/zephyr that referenced this issue Mar 18, 2020
If we can't bind to a device, return -ENODEV and do not continue.

Fixes zephyrproject-rtos#22429
Coverity-ID: 207989

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
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

Successfully merging a pull request may close this issue.

3 participants