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
This commit is contained in:
Ashish Pratap Singh Bhadoria
2022-09-27 20:21:05 +05:30
committed by Gerrit - the friendly Code Review server
parent 6d3f76fb88
commit 4ed6950035

View File

@@ -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;