From patchwork Mon Jan 23 11:56:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schultz X-Patchwork-Id: 718468 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3v6VRw6vMYz9ryQ for ; Mon, 23 Jan 2017 23:07:24 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751096AbdAWMGz (ORCPT ); Mon, 23 Jan 2017 07:06:55 -0500 Received: from mail.tpip.net ([92.43.49.48]:34056 "EHLO mail.tpip.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750723AbdAWMGx (ORCPT ); Mon, 23 Jan 2017 07:06:53 -0500 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 A89554F408; Mon, 23 Jan 2017 11:57:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by office.tpip.net (Postfix) with ESMTP id 7D45EA2CC0; Mon, 23 Jan 2017 12:57:11 +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 G8uypgLSjbR4; Mon, 23 Jan 2017 12:57:11 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by office.tpip.net (Postfix) with ESMTP id 25D72A2CC1; Mon, 23 Jan 2017 12:57:11 +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 p79cBsikKdFc; Mon, 23 Jan 2017 12:57:11 +0100 (CET) Received: from localhost.localdomain (pd95c9392.dip0.t-ipconnect.de [217.92.147.146]) by office.tpip.net (Postfix) with ESMTPSA id D2C8DA2C6B; Mon, 23 Jan 2017 12:57:10 +0100 (CET) From: Andreas Schultz To: Pablo Neira Cc: netdev@vger.kernel.org, Harald Welte , Lionel Gauthier , openbsc@lists.osmocom.org Subject: [PATCH 04/17] gtp: return error ptr in find pdp helpers Date: Mon, 23 Jan 2017 12:56:53 +0100 Message-Id: <20170123115706.4354-5-aschultz@tpip.net> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170123115706.4354-1-aschultz@tpip.net> References: <20170123115706.4354-1-aschultz@tpip.net> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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; }