--- a/kernel/bpf/bpf_struct_ops.c
+++ b/kernel/bpf/bpf_struct_ops.c
@@ -742,8 +742,11 @@ static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,
if (err)
goto reset_unlock;
}
- for (i = 0; i < st_map->image_pages_cnt; i++)
- arch_protect_bpf_trampoline(st_map->image_pages[i], PAGE_SIZE);
+ for (i = 0; i < st_map->image_pages_cnt && !err; i++)
+ err = arch_protect_bpf_trampoline(st_map->image_pages[i], PAGE_SIZE);
+
+ if (err)
nit: Can it be more specific? I mean to check err < 0, so we can reason
that this function never returns a positive value other than 0.