Skip to contentSkip to conversation

ceph: add checking of wait_for_completion_killable() return value

PATCH In review Viacheslav Dubeyko 2 participants 2 messages Jun 6, 2025 – Jun 8, 2025

Subsystems (2)
lore
Share & tools
lore

Viacheslav Dubeyko

author maintainer
#0 lore raw

PATCH 1/1 ceph: add checking of wait_for_completion_killable() return value

From: Viacheslav Dubeyko <[email protected]>

The Coverity Scan service has detected the calling of wait_for_completion_killable() without checking the return value in ceph_lock_wait_for_completion() [1]. The CID 1636232 defect contains explanation: "If the function returns an error value, the error value may be mistaken for a normal value. In ceph_lock_wait_for_completion(): Value returned from a function is not checked for errors before being used. (CWE-252)".

The patch adds the checking of wait_for_completion_killable() return value and return the error code from ceph_lock_wait_for_completion().

[1] https://scan5.scan.coverity.com/#/project-view/64304/10063?selectedIssue=1636232

---
 fs/ceph/locks.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/ceph/locks.c +4 -1
index ebf4ac0055dd..dd764f9c64b9 100644
@@ -221,7 +221,10 @@ static int ceph_lock_wait_for_completion(struct ceph_mds_client *mdsc,
 	if (err && err != -ERESTARTSYS)
 		return err;
 
-	wait_for_completion_killable(&req->r_safe_completion);
+	err = wait_for_completion_killable(&req->r_safe_completion);
+	if (err)
+		return err;
+
 	return 0;
 }
 
Signature · 1 line
2.49.0
maintainer
#1 lore raw

Reviewed by: Alex Markuze <[email protected]>

Quoted 41 lines · Viacheslav Dubeyko

From: Viacheslav Dubeyko <[email protected]>

The Coverity Scan service has detected the calling of wait_for_completion_killable() without checking the return value in ceph_lock_wait_for_completion() [1]. The CID 1636232 defect contains explanation: "If the function returns an error value, the error value may be mistaken for a normal value. In ceph_lock_wait_for_completion(): Value returned from a function is not checked for errors before being used. (CWE-252)".

The patch adds the checking of wait_for_completion_killable() return value and return the error code from ceph_lock_wait_for_completion().

[1] https://scan5.scan.coverity.com/#/project-view/64304/10063?selectedIssue=1636232

---
 fs/ceph/locks.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/ceph/locks.c +4 -2
index ebf4ac0055dd..dd764f9c64b9 100644
@@ -221,7 +221,10 @@ static int ceph_lock_wait_for_completion(struct ceph_mds_client *mdsc,
        if (err && err != -ERESTARTSYS)
                return err;
 
-       wait_for_completion_killable(&req->r_safe_completion);
+       err = wait_for_completion_killable(&req->r_safe_completion);
+       if (err)
+               return err;
+
        return 0;
 }
 
--

2.49.0