Skip to content

Commit

Permalink
Merge pull request #500 from zshi-redhat/bz1958467
Browse files Browse the repository at this point in the history
Bug 1958467: Fix index out of range panic when ifaceName is empty
  • Loading branch information
openshift-merge-robot committed May 26, 2021
2 parents 6ee0cd3 + 3505f3e commit 0401104
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/utils/utils.go
Expand Up @@ -336,6 +336,9 @@ func setNetdevMTU(pciAddr string, mtu int) error {
glog.Warningf("setNetdevMTU(): fail to get interface name for %s: %s", pciAddr, err)
return err
}
if len(ifaceName) < 1 {
return fmt.Errorf("setNetdevMTU(): interface name is empty")
}
mtuFile := "net/" + ifaceName[0] + "/mtu"
mtuFilePath := filepath.Join(sysBusPciDevices, pciAddr, mtuFile)
return ioutil.WriteFile(mtuFilePath, []byte(strconv.Itoa(mtu)), os.ModeAppend)
Expand Down

0 comments on commit 0401104

Please sign in to comment.