Skip to content

Commit

Permalink
mei: bus: disallow driver match while dismantling device
Browse files Browse the repository at this point in the history
With immediate reply support to enum request and
FW reset, a device on MEI bus can be temporarily removed.
A driver for a device on MEI bus can try to bind to the device
right between bus attempt to remove driver and device
structures removal.
This leaves device driver with pointers to freed memory
of device structures.

Avoid bus device driver bind while dismantling device by
disallowing device match right before driver release.

Signed-off-by: Alexander Usyskin <[email protected]>
Signed-off-by: Tomas Winkler <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
ausyskin authored and gregkh committed Feb 8, 2023
1 parent 209cdbd commit 784304a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/misc/mei/bus.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2012-2019, Intel Corporation. All rights reserved.
* Copyright (c) 2012-2023, Intel Corporation. All rights reserved.
* Intel Management Engine Interface (Intel MEI) Linux driver
*/

Expand Down Expand Up @@ -1392,6 +1392,7 @@ static int mei_cl_bus_dev_add(struct mei_cl_device *cldev)
*/
static void mei_cl_bus_dev_stop(struct mei_cl_device *cldev)
{
cldev->do_match = 0;
if (cldev->is_added)
device_release_driver(&cldev->dev);
}
Expand Down

0 comments on commit 784304a

Please sign in to comment.