netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taehee Yoo <ap420073@gmail.com>
To: daniel@iogearbox.net, ast@kernel.org
Cc: bjorn.topel@intel.com, brouer@redhat.com, netdev@vger.kernel.org,
	Taehee Yoo <ap420073@gmail.com>
Subject: [PATCH bpf] xdp: add NULL pointer check in __xdp_return()
Date: Sat, 21 Jul 2018 01:04:45 +0900	[thread overview]
Message-ID: <20180720160445.17475-1-ap420073@gmail.com> (raw)

rhashtable_lookup() can return NULL. so that NULL pointer
check routine should be added.

Fixes: 02b55e5657c3 ("xdp: add MEM_TYPE_ZERO_COPY")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---
 net/core/xdp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/core/xdp.c b/net/core/xdp.c
index 9d1f220..1c12bc7 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -345,7 +345,8 @@ static void __xdp_return(void *data, struct xdp_mem_info *mem, bool napi_direct,
 		rcu_read_lock();
 		/* mem->id is valid, checked in xdp_rxq_info_reg_mem_model() */
 		xa = rhashtable_lookup(mem_id_ht, &mem->id, mem_id_rht_params);
-		xa->zc_alloc->free(xa->zc_alloc, handle);
+		if (xa)
+			xa->zc_alloc->free(xa->zc_alloc, handle);
 		rcu_read_unlock();
 	default:
 		/* Not possible, checked in xdp_rxq_info_reg_mem_model() */
-- 
2.9.3

             reply	other threads:[~2018-07-20 16:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20 16:04 Taehee Yoo [this message]
2018-07-20 17:18 ` [PATCH bpf] xdp: add NULL pointer check in __xdp_return() Martin KaFai Lau
2018-07-20 20:05   ` Jakub Kicinski
2018-07-23  9:39     ` Björn Töpel
2018-07-23 19:58       ` Jakub Kicinski
2018-07-26 12:13         ` Björn Töpel
2018-07-26 18:47           ` Jakub Kicinski
2018-07-21 12:56   ` Taehee Yoo
2018-07-23  9:41     ` Björn Töpel
2018-07-23 13:21       ` Taehee Yoo
2018-08-01 14:14       ` Jesper Dangaard Brouer
2018-08-01 14:43         ` Björn Töpel
2018-08-01 20:25           ` Daniel Borkmann
2018-08-02 10:59             ` Björn Töpel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180720160445.17475-1-ap420073@gmail.com \
    --to=ap420073@gmail.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).