From 5b7bdccb0099d1dff46b68999acbef97c4838d75 Mon Sep 17 00:00:00 2001 From: jeffy Date: Fri, 31 Mar 2023 17:03:00 +0800 Subject: [PATCH] fix: invalid memory address (#2585) * fix: invalid memory address * fix: invalid memory address --------- Co-authored-by: yl4811 --- pkg/controller/vpc_nat.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/controller/vpc_nat.go b/pkg/controller/vpc_nat.go index 1e03f37f45d..b9fbaa19687 100644 --- a/pkg/controller/vpc_nat.go +++ b/pkg/controller/vpc_nat.go @@ -13,9 +13,17 @@ var ( func (c *Controller) resyncVpcNatConfig() { cm, err := c.configMapsLister.ConfigMaps(c.config.PodNamespace).Get(util.VpcNatConfig) - if err != nil && !k8serrors.IsNotFound(err) { + if err != nil { + if k8serrors.IsNotFound(err) { + return + } klog.Errorf("failed to get ovn-vpc-nat-config, %v", err) return } - vpcNatImage = cm.Data["image"] + image, exist := cm.Data["image"] + if !exist { + klog.Errorf("failed to get 'image' at ovn-vpc-nat-config") + return + } + vpcNatImage = image }