BACKPORT: tee: add tee_param_is_memref() for driver use
Change-Id: I105eb7c113b68695c28123f520d8d9b07a1fcda4 Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> (cherry picked from commit 84debcc53533f162bf11f24e6a503d227c175cbe) Signed-off-by: Victor Chong <victor.chong@linaro.org>
This commit is contained in:
parent
014c9019a2
commit
fb96bdaa3a
2 changed files with 14 additions and 14 deletions
|
@ -221,18 +221,6 @@ static int params_to_user(struct tee_ioctl_param __user *uparams,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool param_is_memref(struct tee_param *param)
|
|
||||||
{
|
|
||||||
switch (param->attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) {
|
|
||||||
case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT:
|
|
||||||
case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT:
|
|
||||||
case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int tee_ioctl_open_session(struct tee_context *ctx,
|
static int tee_ioctl_open_session(struct tee_context *ctx,
|
||||||
struct tee_ioctl_buf_data __user *ubuf)
|
struct tee_ioctl_buf_data __user *ubuf)
|
||||||
{
|
{
|
||||||
|
@ -296,7 +284,7 @@ out:
|
||||||
if (params) {
|
if (params) {
|
||||||
/* Decrease ref count for all valid shared memory pointers */
|
/* Decrease ref count for all valid shared memory pointers */
|
||||||
for (n = 0; n < arg.num_params; n++)
|
for (n = 0; n < arg.num_params; n++)
|
||||||
if (param_is_memref(params + n) &&
|
if (tee_param_is_memref(params + n) &&
|
||||||
params[n].u.memref.shm)
|
params[n].u.memref.shm)
|
||||||
tee_shm_put(params[n].u.memref.shm);
|
tee_shm_put(params[n].u.memref.shm);
|
||||||
kfree(params);
|
kfree(params);
|
||||||
|
@ -358,7 +346,7 @@ out:
|
||||||
if (params) {
|
if (params) {
|
||||||
/* Decrease ref count for all valid shared memory pointers */
|
/* Decrease ref count for all valid shared memory pointers */
|
||||||
for (n = 0; n < arg.num_params; n++)
|
for (n = 0; n < arg.num_params; n++)
|
||||||
if (param_is_memref(params + n) &&
|
if (tee_param_is_memref(params + n) &&
|
||||||
params[n].u.memref.shm)
|
params[n].u.memref.shm)
|
||||||
tee_shm_put(params[n].u.memref.shm);
|
tee_shm_put(params[n].u.memref.shm);
|
||||||
kfree(params);
|
kfree(params);
|
||||||
|
|
|
@ -275,4 +275,16 @@ int tee_shm_get_id(struct tee_shm *shm);
|
||||||
*/
|
*/
|
||||||
struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id);
|
struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id);
|
||||||
|
|
||||||
|
static inline bool tee_param_is_memref(struct tee_param *param)
|
||||||
|
{
|
||||||
|
switch (param->attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) {
|
||||||
|
case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT:
|
||||||
|
case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT:
|
||||||
|
case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /*__TEE_DRV_H*/
|
#endif /*__TEE_DRV_H*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue