Skip to content

[Coverity CID: 220535] Dereference before null check in subsys/net/l2/virtual/virtual.c #34006

@zephyrbot

Description

@zephyrbot

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/b86f7addae05add0db45d9b528854235fbb93a48/subsys/net/l2/virtual/virtual.c#L212

Category: Null pointer dereferences
Function: net_virtual_interface_attach
Component: Networking
CID: 220535

Details:

if (virtual_iface && iface) {

206         /* Figure out the link address for this interface. The actual link
207          * address is randomized. This must be done before attach is called so
208          * that the attach callback can create link local address for the
209          * network interface (if IPv6). The actual link address is typically
210          * not need in tunnels.
211          */
>>>     CID 220535:  Null pointer dereferences  (REVERSE_INULL)
>>>     Null-checking "virtual_iface" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
212         if (virtual_iface && iface) {
213             random_linkaddr(ctx->lladdr.addr, sizeof(ctx->lladdr.addr));
214    
215             ctx->lladdr.len = sizeof(ctx->lladdr.addr);
216             ctx->lladdr.type = NET_LINK_UNKNOWN;
217    

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.

Metadata

Metadata

Assignees

Labels

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

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions