Parcourir la source

smcinvoke: Avoid marshalling user args if Callback invocation fails.

Avoid marshalling user args in kernel driver if the corresponding CallBack
invocation fails in userspace.

Change-Id: I1dc5ca562c5a67e1ac2273a1ff2a854f2010c1d3
Ashish Pratap Singh Bhadoria il y a 2 ans
Parent
commit
4ed6950035
1 fichiers modifiés avec 10 ajouts et 4 suppressions
  1. 10 4
      smcinvoke/smcinvoke.c

+ 10 - 4
smcinvoke/smcinvoke.c

@@ -2000,6 +2000,12 @@ static int marshal_out_tzcb_req(const struct smcinvoke_accept *user_req,
 
 	release_tzhandles(&cb_txn->cb_req->hdr.tzhandle, 1);
 	tzcb_req->result = user_req->result;
+        /* Return without marshaling user args if destination callback invocation was
+           unsuccessful. */
+        if (tzcb_req->result != 0) {
+                ret = 0;
+                goto out;
+        }
 	FOR_ARGS(i, tzcb_req->hdr.counts, BO) {
 		union smcinvoke_arg tmp_arg;
 
@@ -2038,12 +2044,12 @@ static int marshal_out_tzcb_req(const struct smcinvoke_accept *user_req,
 		trace_marshal_out_tzcb_req(i, tmp_arg.o.fd,
 				tmp_arg.o.cb_server_fd, tz_args[i].handle);
 	}
-	FOR_ARGS(i, tzcb_req->hdr.counts, OI) {
-		if (TZHANDLE_IS_CB_OBJ(tz_args[i].handle))
-			release_tzhandles(&tz_args[i].handle, 1);
-	}
 	ret = 0;
 out:
+        FOR_ARGS(i, tzcb_req->hdr.counts, OI) {
+                if (TZHANDLE_IS_CB_OBJ(tz_args[i].handle))
+                        release_tzhandles(&tz_args[i].handle, 1);
+        }
 	if (ret)
 		release_tzhandles(tzhandles_to_release, OBJECT_COUNTS_MAX_OO);
 	return ret;