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 :206608] Dereference null return value in tests/net/icmpv4/src/main.c #21699

Closed
zephyrbot opened this issue Jan 4, 2020 · 0 comments · Fixed by #21742
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/c9a2a5e7fb0194bfb168f5aa1a0a83c73f62acb3/tests/net/icmpv4/src/main.c#L184

Category: Null pointer dereferences
Function: test_icmpv4
Component: Tests
CID: 206608

Details:

178    
179         /* ================ Echo Request ================= */
180         net_icmpv4_register_handler(&echo_req_handler);
181    
182         pkt = net_pkt_alloc_with_buffer(NULL, sizeof(icmpv4_echo_req),
183                         AF_UNSPEC, 0, K_SECONDS(1));
>>>     CID 206608:  Null pointer dereferences  (NULL_RETURNS)
>>>     Dereferencing a pointer that might be "NULL" "pkt" when calling "net_pkt_set_ip_hdr_len".
184         net_pkt_set_ip_hdr_len(pkt, sizeof(struct net_ipv4_hdr));
185    
186         zassert_not_null(pkt, "Allocation failed");
187    
188         net_pkt_write(pkt, icmpv4_echo_req, sizeof(icmpv4_echo_req));
189    

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 Jan 4, 2020
jukkar added a commit to jukkar/zephyr that referenced this issue Jan 7, 2020
The code tried to use the allocated pkt ptr before checking for
NULL value.

Fixes zephyrproject-rtos#21699
Coverity-CID: 206608

Signed-off-by: Jukka Rissanen <[email protected]>
jukkar added a commit that referenced this issue Jan 7, 2020
The code tried to use the allocated pkt ptr before checking for
NULL value.

Fixes #21699
Coverity-CID: 206608

Signed-off-by: Jukka Rissanen <[email protected]>
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.

4 participants