Skip to content

Commit

Permalink
aya: Do not use unwrap with btf_fd in bpf_create_map
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
marysaka committed Apr 17, 2023
1 parent 542ada3 commit 7c25fe9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion aya/src/sys/bpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub(crate) fn bpf_create_map(name: &CStr, def: &obj::Map, btf_fd: Option<RawFd>)
_ => {
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;
}
}
}
Expand Down

0 comments on commit 7c25fe9

Please sign in to comment.