Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp555104imm; Wed, 25 Jul 2018 01:55:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfKuTG84i7Chf7A0QQyVvJRJDxJ2pirm3mNpG/OLtGnYz2Hb9AS8G8I3PNPdlOsI1v4W6SU X-Received: by 2002:a17:902:b28c:: with SMTP id u12-v6mr19914568plr.16.1532508953185; Wed, 25 Jul 2018 01:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532508953; cv=none; d=google.com; s=arc-20160816; b=JuQ28j/eCi+AgrhVIccZNG0K7fZ+Pxw1Nmvrr39pJmFGgRPOwiVnoX0lRLhePErT2X 8WKLCtD3n+ER1uho6GksOFuI7QsqP8ySbofNnjuI+vHsF4wh6k5PsHKE0GleSXg0nPgk L8SuwJ1Svadr1yEMQoSb14mlvMwGMxqN6ZJxVGd9S2v9gcErOWc7jdZMvYJ5gwDx54KM 64pXl42tDIgkuFB1363cowOj3UtgTnBe3i1WYLT1CRPRO/SCihdR0tnD8mhVpS+IC6su V6FgF+WljvMct4E7s7Pfjz8XiI+Ar94YxAGYzs3DEFOXZNU6HNUFaup75aC54QacA6Yb yYjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=fuZCs/EGCUvtPuVIzImnC3qCdZTnr3AGVrv1UqO2niM=; b=eDKs8K4B70CNSmkqy2VKL+s0JxPLK2s/DvsUDL85c17DsFAXloPn4UDF/0QCbQxcOx 3dVcWFrfkKbC7Qjsc0WZhGq6SWdWwdoB2v6ZirTUNMW/lc9vymgp64IBovl1hnTRNrsb foWK3xczcjCM3hjcLFdCW4BE09GFUkWCa0Q8XTgrtd//6jIU6WtG69RMWWFau59muR3q jBgB9F9Fq1+ujNAx4ThzQraSqKqWYxxrbczdGZG8nAUJjjLJpYM0V48oy+D9ajwsM5kZ TAUy+yLY0AxYJTE9S/eNQHNJxMf+K2t0V9aMnEX5dPK3GAH9oV5RFxtlJw+XmOi+AgE6 qrfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19-v6si1885493plp.298.2018.07.25.01.55.37; Wed, 25 Jul 2018 01:55:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728644AbeGYKFb (ORCPT + 99 others); Wed, 25 Jul 2018 06:05:31 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9718 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728126AbeGYKFa (ORCPT ); Wed, 25 Jul 2018 06:05:30 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 3FABF3187C066; Wed, 25 Jul 2018 16:54:45 +0800 (CST) Received: from localhost (10.177.31.96) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.382.0; Wed, 25 Jul 2018 16:54:40 +0800 From: YueHaibing To: , , CC: , , YueHaibing Subject: [PATCH ipsec-next] xfrm: fix 'passing zero to ERR_PTR()' warning Date: Wed, 25 Jul 2018 16:54:33 +0800 Message-ID: <20180725085433.18756-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.31.96] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix a static code checker warning: net/xfrm/xfrm_policy.c:1836 xfrm_resolve_and_create_bundle() warn: passing zero to 'ERR_PTR' xfrm_tmpl_resolve return 0 just means no xdst found, return NULL instead of passing zero to ERR_PTR. Fixes: d809ec895505 ("xfrm: do not assume that template resolving always returns xfrms") Signed-off-by: YueHaibing --- net/xfrm/xfrm_policy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 5f48251..4adbeb2 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -1831,7 +1831,10 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols, /* Try to instantiate a bundle */ err = xfrm_tmpl_resolve(pols, num_pols, fl, xfrm, family); if (err <= 0) { - if (err != 0 && err != -EAGAIN) + if (err == 0) + return NULL; + + if (err != -EAGAIN) XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR); return ERR_PTR(err); } -- 2.7.0