Fix missing devices unregister during optee_remove
Unregisters OP-TEE client devices (UUIDs of some known Trusted Applications) from the TEE bus when the OP-TEE driver is unloaded. -----BEGIN PGP SIGNATURE----- iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmFmzW4aHGplbnMud2lr bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJcyrQ//Utl1/sIMNrGT2wk2fU5A aN7vrWzUBv+VH5zZ1yTqNGEvuu/IJJ+9+wAz6DNVB/vaDCak/VX9toNJX+SwsanN 2qqrAeQPDnHJEaFBul/ogz2RN9pU66NwIeYVdYmkyE0rBtIjgbDOG7f2uPEpKVVj dTfX69QFohsD/Amnz6G4+vr8olEtrhDcODgcq2FnXhGiTl1PVY397k+MpNzUopvO 0+hWOzPGs14Y0axornZcT/Y2mYp7fGMna+KtLauBHft44xDNp5Qgd5jOZjFfpUxh wJXaBsYti1OgYdS8gPvpC20bpC22iqYd3R+WapRvT5PxEsx2GLaWtoG+gBGJ4SDd T2EOf/XHcHsaY/iYqG2ICwbAjDLgvGgoqXa4A6jIzR6z3/WFtrjCN1M0W3TXQSXC 6IIYpsYaVKFMK4wcmhNTXylltegOtnCMfvMkI8kXj27PVkKgQypk/DrAHO5qP/fZ UbOWFFq8fziWHO+K6txTqMRO7DyuJlleRDYiZ3Y6ED+M8eQ4Ejl2i9KqboV+ljKC /lHOmbPEB0EGzWxDvPT+XZu+19/NFPmj6ILdNbsEMNUxtYKZj6HU0s8wEOx0M/yw 5rZY4D2g40QKEl6QzI9s2SN623+Mhl5tgi0qcMOo7QHLrJatXpgptPgTtwgV1VAZ numJsMBTCEfDxhNiyLuTm2s= =WXLA -----END PGP SIGNATURE----- gpgsig -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmFnMLYACgkQmmx57+YA GNkKLg/9H3iRbiksUw9WyAMJz8C+rNcB8ftucWPwFIx3zBKumc4t7iLKbUUQHyzF 1fvXUKO/PxfzdJ50uwFHHz2SxZwAKQQU0IhwchPM1e5ubFWZvYC9ycvzWV8orUG4 c1w4FlP8jXrzTx5cNvpr2E3GMhTjjIgmbMXEww7bNH3HeQ7xN4q8o7olYRRsYHpM DJZWAFb1XDxWwlftVglFUDyWrJlLxa1S2OQWVR8KLY37Ff1L5vyEFiXnjDuwIzeG AuJGl9RlxW3UT6vTkhb0g9hpqKPtn0xc85Dd4hrg52OSvIzpuN99mG2f3AqPzgbi T5EtM0tQ7E7F8UdPqtVP6ib9nNAutBgadje34vHLurOZ9Td1FllInFUTioyyPsop B/sAAfpQRt84R/NEms3sm6sHK2vsf8RY1FwwmNRncrkxZmHV/Glt6bAXxs3Z1Wsx vlXOYIAqF4sTU4wQCSJe6dsiqn1Bhgl/uUYurwufPf6dcI646+pGlBlMxTTYEmNq Hbzcvd/QaBkRiHD2sguctXotSPpAGUX/zEua7koOl5kMQEX+VRQdGqJMhgW5N/P1 xMVeKDPvbiKUK41YFeO4y1fEaSGON/JSvZRmr4zRCFwFH1RIobH/z3zo90VS9z5y CPg12UIqdDf5Vy/Z8qW1AoovJIGF71lRVr4wCESGNwoQzXPtzLI= =HZ3a -----END PGP SIGNATURE----- Merge tag 'optee-fix2-for-v5.15' of git://git.linaro.org/people/jens.wiklander/linux-tee into arm/fixes Fix missing devices unregister during optee_remove Unregisters OP-TEE client devices (UUIDs of some known Trusted Applications) from the TEE bus when the OP-TEE driver is unloaded. * tag 'optee-fix2-for-v5.15' of git://git.linaro.org/people/jens.wiklander/linux-tee: tee: optee: Fix missing devices unregister during optee_remove Link: https://lore.kernel.org/r/20211013122854.GA1542549@jade Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
commit
3536ac5d77
@ -585,6 +585,9 @@ static int optee_remove(struct platform_device *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
|
||||
* 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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
struct tee_client_device *optee_device = NULL;
|
||||
@ -63,6 +70,7 @@ static int optee_register_device(const uuid_t *device_uuid)
|
||||
return -ENOMEM;
|
||||
|
||||
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)) {
|
||||
kfree(optee_device);
|
||||
return -ENOMEM;
|
||||
@ -154,3 +162,17 @@ int optee_enumerate_devices(u32 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_SUPP 0x1
|
||||
int optee_enumerate_devices(u32 func);
|
||||
void optee_unregister_devices(void);
|
||||
|
||||
/*
|
||||
* Small helpers
|
||||
|
Loading…
Reference in New Issue
Block a user