aboutsummaryrefslogtreecommitdiff
path: root/kernel/ethosu_device.c
diff options
context:
space:
mode:
authorMikael Olsson <mikael.olsson@arm.com>2023-06-14 17:14:14 +0200
committerMikael Olsson <mikael.olsson@arm.com>2023-08-09 11:26:32 +0200
commit529cfad55fa3b52ed8c78ad486812e7bcf56add6 (patch)
treefe9f6213b710bf5dabe343e600954bc530d09f15 /kernel/ethosu_device.c
parentf1e675acd79af01bb458338cb0f992b30425ebf9 (diff)
downloadethos-u-linux-driver-stack-529cfad55fa3b52ed8c78ad486812e7bcf56add6.tar.gz
Fix concurrent access to IDR in kernel driver
The IDR instance must be protected against concurrent access and the device mutex in the kernel driver should be used to protect it. However, the device mutex is not locked when an inference is released or when the mailbox is cleared which means the IDR is not protected in these instances. To resolve this, the missing mutex locks have been added and the functions using the IDR instance have been updated to make it clearer that the device mutex is expected to be locked when called. Change-Id: Id0b314db556836c36663d6481806b7c113e55e5f Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
Diffstat (limited to 'kernel/ethosu_device.c')
-rw-r--r--kernel/ethosu_device.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/ethosu_device.c b/kernel/ethosu_device.c
index 1a2e7f7..ae257c3 100644
--- a/kernel/ethosu_device.c
+++ b/kernel/ethosu_device.c
@@ -522,7 +522,10 @@ void ethosu_dev_deinit(struct rpmsg_device *rpdev)
dev_info(dev, "%s", __FUNCTION__);
+ device_lock(&edev->dev);
ethosu_mailbox_fail(&edev->mailbox);
+ device_unlock(&edev->dev);
+
rpmsg_destroy_ept(edev->ept);
cdev_del(&edev->cdev);
device_unregister(&edev->dev);