Skip to content

Commit c5e42b7

Browse files
committed
mei: bus: Check for still connected devices in mei_cl_bus_dev_release()
JIRA: https://issues.redhat.com/browse/RHEL-113185 commit 35e8a42 Author: Hans de Goede <hansg@kernel.org> Date: Mon Jun 23 10:50:52 2025 +0200 mei: bus: Check for still connected devices in mei_cl_bus_dev_release() mei_cl_bus_dev_release() also frees the mei-client (struct mei_cl) belonging to the device being released. If there are bugs like the just fixed bug in the ACE/CSI2 mei drivers, the mei-client being freed might still be part of the mei_device's file_list and iterating over this list after the freeing will then trigger a use-afer-free bug. Add a check to mei_cl_bus_dev_release() to make sure that the to-be-freed mei-client is not on the mei_device's file_list. Signed-off-by: Hans de Goede <hansg@kernel.org> Link: https://lore.kernel.org/r/20250623085052.12347-11-hansg@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Steve Best <sbest@redhat.com>
1 parent 241eeac commit c5e42b7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/misc/mei/bus.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,10 +1300,16 @@ static void mei_dev_bus_put(struct mei_device *bus)
13001300
static void mei_cl_bus_dev_release(struct device *dev)
13011301
{
13021302
struct mei_cl_device *cldev = to_mei_cl_device(dev);
1303+
struct mei_device *mdev = cldev->cl->dev;
1304+
struct mei_cl *cl;
13031305

13041306
mei_cl_flush_queues(cldev->cl, NULL);
13051307
mei_me_cl_put(cldev->me_cl);
13061308
mei_dev_bus_put(cldev->bus);
1309+
1310+
list_for_each_entry(cl, &mdev->file_list, link)
1311+
WARN_ON(cl == cldev->cl);
1312+
13071313
kfree(cldev->cl);
13081314
kfree(cldev);
13091315
}

0 commit comments

Comments
 (0)