[2/5] bpf: Move an assignment for the variable “st_map” in bpf_struct_ops_link_create()

Message ID ed2f5323-390f-4c9d-919d-df43ba1cad2b@web.de
State New
Headers
Series [1/5] bpf: Improve exception handling in bpf_struct_ops_link_create() |

Commit Message

Markus Elfring Dec. 30, 2023, 8:08 p.m. UTC
  From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 30 Dec 2023 19:00:12 +0100

Move one assignment for the variable “st_map” closer to the place
where this pointer is used.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/bpf/bpf_struct_ops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--
2.43.0
  

Patch

diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c
index b49ea460d616..4133d65c2a28 100644
--- a/kernel/bpf/bpf_struct_ops.c
+++ b/kernel/bpf/bpf_struct_ops.c
@@ -898,8 +898,6 @@  int bpf_struct_ops_link_create(union bpf_attr *attr)
 	if (IS_ERR(map))
 		return PTR_ERR(map);

-	st_map = (struct bpf_struct_ops_map *)map;
-
 	if (!bpf_struct_ops_valid_to_reg(map)) {
 		err = -EINVAL;
 		goto put_map;
@@ -916,6 +914,7 @@  int bpf_struct_ops_link_create(union bpf_attr *attr)
 	if (err)
 		goto err_out;

+	st_map = (struct bpf_struct_ops_map *)map;
 	err = st_map->st_ops->reg(st_map->kvalue.data);
 	if (err) {
 		bpf_link_cleanup(&link_primer);