tee: optee: Fix missing devices unregister during optee_remove
When OP-TEE driver is built as a module, OP-TEE client devices
registered on TEE bus during probe should be unregistered during
optee_remove. So implement optee_unregister_devices() accordingly.
Fixes: c3fa24af92
("tee: optee: add TEE bus device enumeration support")
Reported-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
This commit is contained in:
parent
88a3856c0a
commit
7f565d0ead
|
@ -585,6 +585,9 @@ static int optee_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct optee *optee = platform_get_drvdata(pdev);
|
struct optee *optee = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
/* Unregister OP-TEE specific client devices on TEE bus */
|
||||||
|
optee_unregister_devices();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ask OP-TEE to free all cached shared memory objects to decrease
|
* Ask OP-TEE to free all cached shared memory objects to decrease
|
||||||
* reference counters and also avoid wild pointers in secure world
|
* reference counters and also avoid wild pointers in secure world
|
||||||
|
|
|
@ -53,6 +53,13 @@ static int get_devices(struct tee_context *ctx, u32 session,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void optee_release_device(struct device *dev)
|
||||||
|
{
|
||||||
|
struct tee_client_device *optee_device = to_tee_client_device(dev);
|
||||||
|
|
||||||
|
kfree(optee_device);
|
||||||
|
}
|
||||||
|
|
||||||
static int optee_register_device(const uuid_t *device_uuid)
|
static int optee_register_device(const uuid_t *device_uuid)
|
||||||
{
|
{
|
||||||
struct tee_client_device *optee_device = NULL;
|
struct tee_client_device *optee_device = NULL;
|
||||||
|
@ -63,6 +70,7 @@ static int optee_register_device(const uuid_t *device_uuid)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
optee_device->dev.bus = &tee_bus_type;
|
optee_device->dev.bus = &tee_bus_type;
|
||||||
|
optee_device->dev.release = optee_release_device;
|
||||||
if (dev_set_name(&optee_device->dev, "optee-ta-%pUb", device_uuid)) {
|
if (dev_set_name(&optee_device->dev, "optee-ta-%pUb", device_uuid)) {
|
||||||
kfree(optee_device);
|
kfree(optee_device);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -154,3 +162,17 @@ int optee_enumerate_devices(u32 func)
|
||||||
{
|
{
|
||||||
return __optee_enumerate_devices(func);
|
return __optee_enumerate_devices(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __optee_unregister_device(struct device *dev, void *data)
|
||||||
|
{
|
||||||
|
if (!strncmp(dev_name(dev), "optee-ta", strlen("optee-ta")))
|
||||||
|
device_unregister(dev);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void optee_unregister_devices(void)
|
||||||
|
{
|
||||||
|
bus_for_each_dev(&tee_bus_type, NULL, NULL,
|
||||||
|
__optee_unregister_device);
|
||||||
|
}
|
||||||
|
|
|
@ -184,6 +184,7 @@ void optee_fill_pages_list(u64 *dst, struct page **pages, int num_pages,
|
||||||
#define PTA_CMD_GET_DEVICES 0x0
|
#define PTA_CMD_GET_DEVICES 0x0
|
||||||
#define PTA_CMD_GET_DEVICES_SUPP 0x1
|
#define PTA_CMD_GET_DEVICES_SUPP 0x1
|
||||||
int optee_enumerate_devices(u32 func);
|
int optee_enumerate_devices(u32 func);
|
||||||
|
void optee_unregister_devices(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Small helpers
|
* Small helpers
|
||||||
|
|
Loading…
Reference in New Issue