[1/4] action-scripts: check a return code of get_service_fd

Submitted by Andrei Vagin on May 15, 2018, 10:55 p.m.

Details

Message ID 20180515225559.7309-1-avagin@virtuozzo.com
State Accepted
Series "Series without cover letter"
Headers show

Commit Message

Andrei Vagin May 15, 2018, 10:55 p.m.
>>>     CID 190177:  Integer handling issues  (NEGATIVE_RETURNS)
>>>     rpc_sk is passed to a parameter that cannot be negative.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
 criu/action-scripts.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/action-scripts.c b/criu/action-scripts.c
index 3cbe89ee4..7b78a1360 100644
--- a/criu/action-scripts.c
+++ b/criu/action-scripts.c
@@ -108,6 +108,8 @@  int rpc_send_fd(enum script_actions act, int fd)
 		return -1;
 
 	rpc_sk = get_service_fd(RPC_SK_OFF);
+	if (rpc_sk < 0)
+		return -1;
 
 	pr_debug("\tRPC\n");
 	return send_criu_rpc_script(act, (char *)action, rpc_sk, fd);
@@ -128,6 +130,10 @@  int run_scripts(enum script_actions act)
 
 		pr_debug("\tRPC\n");
 		rpc_sk = get_service_fd(RPC_SK_OFF);
+		if (rpc_sk < 0) {
+			ret = -1;
+			goto out;
+		}
 		ret = send_criu_rpc_script(act, (char *)action, rpc_sk, -1);
 		goto out;
 	}