From 7c25fe90a9611545aba047cd347ca431616130b6 Mon Sep 17 00:00:00 2001 From: Mary Date: Mon, 17 Apr 2023 15:08:49 +0200 Subject: [PATCH] aya: Do not use unwrap with btf_fd in bpf_create_map Fixes a crash when trying to create a map of type BPF_MAP_TYPE_PERCPU_ARRAY when btf_fd is None. Tested on Ubuntu 18.04 (4.15.0-202-generic) --- aya/src/sys/bpf.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs index 101823d7..17149377 100644 --- a/aya/src/sys/bpf.rs +++ b/aya/src/sys/bpf.rs @@ -66,7 +66,7 @@ pub(crate) fn bpf_create_map(name: &CStr, def: &obj::Map, btf_fd: Option) _ => { u.btf_key_type_id = m.def.btf_key_type_id; u.btf_value_type_id = m.def.btf_value_type_id; - u.btf_fd = btf_fd.unwrap() as u32; + u.btf_fd = btf_fd.unwrap_or_default() as u32; } } }