github-vet / github-vet/rangeloop-pointer-findings

openshift/sriov-network-operator: pkg/webhook/validate.go; 14 LoC

Open
#16,934 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [openshift/sriov-network-operator](https://www.github.com/openshift/sriov-network-operator) at [pkg/webhook/validate.go](https://github.com/openshift/sriov-network-operator/blob/d6033c0821a1cd095789135c0a31a8eac9dd5a8c/pkg/webhook/validate.go#L203-L216)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.

> function call which takes a reference to iface at line 204 may start a goroutine

[Click here to see the code in its original context.](https://github.com/openshift/sriov-network-operator/blob/d6033c0821a1cd095789135c0a31a8eac9dd5a8c/pkg/webhook/validate.go#L203-L216)

Click here to show the 14 line(s) of Go which triggered the analyzer.

```go
for _, iface := range state.Status.Interfaces {
if validateNicModel(&policy.Spec.NicSelector, &iface, state.GetName()) {
interfaceSelected = true
if policy.GetName() != "default" && policy.Spec.NumVfs == 0 {
return false, fmt.Errorf("numVfs(%d) in CR %s is not allowed", policy.Spec.NumVfs, policy.GetName())
}
if policy.Spec.NumVfs > iface.TotalVfs && iface.Vendor == IntelID {
return false, fmt.Errorf("numVfs(%d) in CR %s exceed the maximum allowed value(%d)", policy.Spec.NumVfs, policy.GetName(), iface.TotalVfs)
}
if policy.Spec.NumVfs > MlxMaxVFs && iface.Vendor == MellanoxID {
return false, fmt.Errorf("numVfs(%d) in CR %s exceed the maximum allowed value(%d)", policy.Spec.NumVfs, policy.GetName(), MlxMaxVFs)
}
}
}

```

Click here to show extra information the analyzer produced.

```
The following graphviz dot graph describes paths through the callgraph that could lead to a function calling a goroutine:
digraph G {
"(Set, 1)" -> {"(New, 1)";}
"(SetTransportDefaults, 1)" -> {"(ConfigureTransport, 1)";}
"(Get, 3)" -> {"(Set, 1)";}
"(New, 1)" -> {"(get, 1)";}
"(get, 1)" -> {"(SetTransportDefaults, 1)";}
"(ConfigureTransport, 1)" -> {"(configureTransport, 1)";}
"(configureTransport, 1)" -> {"(addConnIfNeeded, 3)";}
"(addConnIfNeeded, 3)" -> {}
"(validateNicModel, 3)" -> {"(Get, 3)";}
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: d6033c0821a1cd095789135c0a31a8eac9dd5a8c

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.