From patchwork Tue Jan 24 15:28:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schultz X-Patchwork-Id: 719195 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id 3v7BtC4YZ0z9sxS for ; Wed, 25 Jan 2017 02:29:07 +1100 (AEDT) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 642BF28037; Tue, 24 Jan 2017 15:29:03 +0000 (UTC) Authentication-Results: lists.osmocom.org; dmarc=none header.from=tpip.net X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=92.43.49.48; helo=mail.tpip.net; envelope-from=aschultz@tpip.net; receiver=openbsc@lists.osmocom.org Authentication-Results: lists.osmocom.org; dmarc=none header.from=tpip.net Received: from mail.tpip.net (mail.tpip.net [92.43.49.48]) by lists.osmocom.org (Postfix) with ESMTP id 601DE29EF3 for ; Tue, 24 Jan 2017 15:28:54 +0000 (UTC) Received: from office.tpip.net (unknown [153.92.65.89]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.tpip.net (Postfix) with ESMTPS id EC63B4F408; Tue, 24 Jan 2017 15:28:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by office.tpip.net (Postfix) with ESMTP id C3A89A2CC2; Tue, 24 Jan 2017 16:28:53 +0100 (CET) Received: from office.tpip.net ([127.0.0.1]) by localhost (office.tpip.net [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id ioj9npLMsYgk; Tue, 24 Jan 2017 16:28:53 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by office.tpip.net (Postfix) with ESMTP id 63288A2CC3; Tue, 24 Jan 2017 16:28:53 +0100 (CET) X-Virus-Scanned: amavisd-new at tpip.net Received: from office.tpip.net ([127.0.0.1]) by localhost (office.tpip.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id NyFS4B0BoKNU; Tue, 24 Jan 2017 16:28:53 +0100 (CET) Received: from localhost.localdomain (pd95c9392.dip0.t-ipconnect.de [217.92.147.146]) by office.tpip.net (Postfix) with ESMTPSA id 1C53AA2CC0; Tue, 24 Jan 2017 16:28:53 +0100 (CET) From: Andreas Schultz To: Pablo Neira Subject: [PATCH v2 04/18] gtp: return error ptr in find pdp helpers Date: Tue, 24 Jan 2017 16:28:34 +0100 Message-Id: <20170124152848.6120-5-aschultz@tpip.net> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170124152848.6120-1-aschultz@tpip.net> References: <20170124152848.6120-1-aschultz@tpip.net> X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of OpenBSC, OsmoBSC, OsmoNITB, OsmoCSCN" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbsc@lists.osmocom.org, Lionel Gauthier Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" Signed-off-by: Andreas Schultz --- drivers/net/gtp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 60946b7..e95c856 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -114,7 +114,7 @@ static struct pdp_ctx *gtp0_pdp_find(struct gtp_dev *gtp, u64 tid) pdp->u.v0.tid == tid) return pdp; } - return NULL; + return ERR_PTR(-ENOENT); } /* Resolve a PDP context structure based on the 32bit TEI. */ @@ -130,7 +130,7 @@ static struct pdp_ctx *gtp1_pdp_find(struct gtp_dev *gtp, u32 tid) pdp->u.v1.i_tei == tid) return pdp; } - return NULL; + return ERR_PTR(-ENOENT); } /* Resolve a PDP context based on IPv4 address of MS. */ @@ -147,7 +147,7 @@ static struct pdp_ctx *ipv4_pdp_find(struct gtp_dev *gtp, __be32 ms_addr) return pdp; } - return NULL; + return ERR_PTR(-ENOENT); } static bool gtp_check_src_ms_ipv4(struct sk_buff *skb, struct pdp_ctx *pctx, @@ -199,7 +199,7 @@ static int gtp0_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb, rcu_read_lock(); pctx = gtp0_pdp_find(gtp, be64_to_cpu(gtp0->tid)); - if (!pctx) { + if (IS_ERR(pctx)) { netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb); ret = -1; goto out_rcu; @@ -256,7 +256,7 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb, rcu_read_lock(); pctx = gtp1_pdp_find(gtp, ntohl(gtp1->tid)); - if (!pctx) { + if (IS_ERR(pctx)) { netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb); ret = -1; goto out_rcu; @@ -476,10 +476,10 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev, */ iph = ip_hdr(skb); pctx = ipv4_pdp_find(gtp, iph->daddr); - if (!pctx) { + if (IS_ERR(pctx)) { netdev_dbg(dev, "no PDP ctx found for %pI4, skip\n", &iph->daddr); - return -ENOENT; + return PTR_ERR(pctx); } netdev_dbg(dev, "found PDP context %p\n", pctx); @@ -1085,8 +1085,8 @@ static int gtp_genl_del_pdp(struct sk_buff *skb, struct genl_info *info) return -EINVAL; } - if (pctx == NULL) - return -ENOENT; + if (IS_ERR(pctx)) + return PTR_ERR(pctx); if (pctx->gtp_version == GTP_V0) netdev_dbg(dev, "GTPv0-U: deleting tunnel id = %llx (pdp %p)\n", @@ -1194,8 +1194,8 @@ static int gtp_genl_get_pdp(struct sk_buff *skb, struct genl_info *info) pctx = ipv4_pdp_find(gtp, ip); } - if (pctx == NULL) { - err = -ENOENT; + if (IS_ERR(pctx)) { + err = PTR_ERR(pctx); goto err_unlock; }