Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
network: Correct error reporting in listInterfaces()
Browse files Browse the repository at this point in the history
There are two problems with error reporting here.
  1) If the upcast from resultingInterfaces to *grpc.Interfaces fails, we
     return (nil, err), but previous code ensures that err is nil at that
     point, so we return no error.

  2) Due to shadowing the err variable, if an error is reported by
     convertToInterfaces, we'll also return (nil, nil) in that case

fixes #3032

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
  • Loading branch information
dgibson committed Oct 29, 2020
1 parent 9380b6e commit b86e904
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,13 +672,10 @@ func (k *kataAgent) listInterfaces() ([]*vcTypes.Interface, error) {
return nil, err
}
resultInterfaces, ok := resultingInterfaces.(*grpc.Interfaces)
if ok {
ifaces, err := k.convertToInterfaces(resultInterfaces.Interfaces)
if err == nil {
return ifaces, nil
}
if !ok {
return nil, fmt.Errorf("Unexpected type %T for interfaces", resultingInterfaces)
}
return nil, err
return k.convertToInterfaces(resultInterfaces.Interfaces)
}

func (k *kataAgent) listRoutes() ([]*vcTypes.Route, error) {
Expand Down

0 comments on commit b86e904

Please sign in to comment.