Skip to contentSkip to conversation

samples/seccomp: fix error return code in handle_req()

PATCH New Zhen Lei 1 participant 1 message May 8, 2021

lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 samples/seccomp: fix error return code in handle_req()

Unlike branch "if (lseek(mem, req->data.args[0], SEEK_SET) < 0)" above, 'ret' is overwritten by the previous 'ret = read(...)' statement. Therefore, 'ret' needs to be explicitly assigned to -1 here. Otherwise, 0 is incorrectly returned.

---
 samples/seccomp/user-trap.c | 1 +
 1 file changed, 1 insertion(+)
samples/seccomp/user-trap.c +1 -0
index 20291ec6489f..c1d4ca0284ba 100644
@@ -164,6 +164,7 @@ static int handle_req(struct seccomp_notif *req,
 	}
 
 	if (lseek(mem, req->data.args[1], SEEK_SET) < 0) {
+		ret = -1;
 		perror("seek");
 		goto out;
 	}
Signature · 1 line
2.25.1