Skip to content

Commit 94c2f2e

Browse files
etienne-lmsjforissier
authored andcommitted
tee: fix unbalanced context refcount in register shm from fd
Successful registration of a memory reference in the scope of a TEE content must increase the context refcount. This change adds this missing refcount increase. The context refcount is already decremented when such shm reference is freed by its owner, in tee_shm_release(), hence current unbalance refcount before this path is applied. Fixes: 9f9806e ("tee: new ioctl to a register tee_shm from a dmabuf file descriptor") Signed-off-by: Etienne Carriere <[email protected]> Tested-by: Etienne Carriere <[email protected]> (Qemu armv7/v8) Acked-by: Jens Wiklander <[email protected]>
1 parent 3ed4ce4 commit 94c2f2e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/tee/tee_shm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ struct tee_shm *tee_shm_register_fd(struct tee_context *ctx, int fd)
372372
if (!tee_device_get(ctx->teedev))
373373
return ERR_PTR(-EINVAL);
374374

375+
teedev_ctx_get(ctx);
376+
375377
ref = kzalloc(sizeof(*ref), GFP_KERNEL);
376378
if (!ref) {
377379
rc = ERR_PTR(-ENOMEM);
@@ -452,6 +454,7 @@ struct tee_shm *tee_shm_register_fd(struct tee_context *ctx, int fd)
452454
dma_buf_put(ref->dmabuf);
453455
}
454456
kfree(ref);
457+
teedev_ctx_put(ctx);
455458
tee_device_put(ctx->teedev);
456459
return rc;
457460
}

0 commit comments

Comments
 (0)