Skip to content

Commit 67ad2c7

Browse files
Hou TaoAlexei Starovoitov
authored andcommitted
bpf: Only call maybe_wait_bpf_programs() when map operation succeeds
There is no need to call maybe_wait_bpf_programs() if update or deletion operation fails. So only call maybe_wait_bpf_programs() if update or deletion operation succeeds. Signed-off-by: Hou Tao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 0127725 commit 67ad2c7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/bpf/syscall.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,8 @@ static int map_update_elem(union bpf_attr *attr, bpfptr_t uattr)
15761576
}
15771577

15781578
err = bpf_map_update_value(map, f.file, key, value, attr->flags);
1579-
maybe_wait_bpf_programs(map);
1579+
if (!err)
1580+
maybe_wait_bpf_programs(map);
15801581

15811582
kvfree(value);
15821583
free_key:
@@ -1632,7 +1633,8 @@ static int map_delete_elem(union bpf_attr *attr, bpfptr_t uattr)
16321633
err = map->ops->map_delete_elem(map, key);
16331634
rcu_read_unlock();
16341635
bpf_enable_instrumentation();
1635-
maybe_wait_bpf_programs(map);
1636+
if (!err)
1637+
maybe_wait_bpf_programs(map);
16361638
out:
16371639
kvfree(key);
16381640
err_put:

0 commit comments

Comments
 (0)