netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taehee Yoo <ap420073@gmail.com>
To: daniel@iogearbox.net, ast@kernel.org, bjorn.topel@intel.com
Cc: brouer@redhat.com, netdev@vger.kernel.org,
	Taehee Yoo <ap420073@gmail.com>
Subject: [PATCH V2 bpf] xdp: add NULL pointer check in __xdp_return()
Date: Thu, 26 Jul 2018 00:09:50 +0900	[thread overview]
Message-ID: <20180725150950.23298-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>
---
V2 : add WARN_ON_ONCE when xa is NULL.

 net/core/xdp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/core/xdp.c b/net/core/xdp.c
index 9d1f220..786fdbe 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -345,7 +345,10 @@ 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)
+			WARN_ON_ONCE(1);
+		else
+			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-25 16:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25 15:09 Taehee Yoo [this message]
2018-07-25 20:50 ` [PATCH V2 bpf] xdp: add NULL pointer check in __xdp_return() Martin KaFai Lau
2018-07-26  2:11 ` Jakub Kicinski
2018-07-26 12:07   ` Björn Töpel
2018-07-26 14:05     ` Taehee Yoo
2018-07-26 14:02   ` Taehee Yoo

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=20180725150950.23298-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).