xdp: add NULL pointer check in __xdp_return()
Subsystems (3)
PATCH v3 1/1 xdp: add NULL pointer check in __xdp_return()
rhashtable_lookup() can return NULL. so that NULL pointer check routine should be added.
Fixes 02b55e5657c3 ("xdp: add MEM_TYPE_ZERO_COPY")
Acked-by Martin KaFai Lau <[email protected]>
Signed-off-by Taehee Yoo <[email protected]>
---
V3 : reduce code line
V2 : add WARN_ON_ONCE when xa is NULL.
net/core/xdp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/xdp.c +2 -1
@@ -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 (!WARN_ON_ONCE (!xa)) + xa->zc_alloc->free (xa->zc_alloc, handle);rcu_read_unlock ();default :/* Not possible, checked in xdp_rxq_info_reg_mem_model() */
Signature · 1 line
2.9.3
Den tors 26 juli 2018 kl 16:18 skrev Taehee Yoo <[email protected]>:
Quoted 4 lines
rhashtable_lookup()can return NULL. so that NULL pointer check routine should be added.
Thanks Taehee!
Acked-by Björn Töpel <[email protected]>
Quoted 26 lines
Fixes 02b55e5657c3 ("xdp: add MEM_TYPE_ZERO_COPY")Acked-by Martin KaFai Lau <[email protected]>Signed-off-by Taehee Yoo <[email protected]>---
V3 : reduce code line
V2 : addWARN_ON_ONCEwhen xa is NULL.net/core/xdp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)net/core/xdp.c +2
-2@@ -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 (!WARN_ON_ONCE (!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
Quoted 6 lines · Taehee Yoo
rhashtable_lookup()can return NULL. so that NULL pointer check routine should be added.Fixes 02b55e5657c3 ("xdp: add MEM_TYPE_ZERO_COPY")Acked-by Martin KaFai Lau <[email protected]>Signed-off-by Taehee Yoo <[email protected]>
Applied to bpf, thanks Taehee!