From 0d16710146a10cf62b3efddee8ffd006432d5d7e Mon Sep 17 00:00:00 2001 From: Michal Wilczynski Date: Mon, 3 Jul 2023 11:02:45 +0300 Subject: [PATCH] ACPI: bus: Set driver_data to NULL every time .add() fails Most ACPI drivers set driver_data in their .add() callbacks, but usually they don't clear it in the error code path. Set driver_data to NULL in acpi_device_probe() to prevent stale pointers from staying around. Signed-off-by: Michal Wilczynski [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki --- drivers/acpi/bus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index b568883..0168b3a 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1029,8 +1029,10 @@ static int acpi_device_probe(struct device *dev) return -ENOSYS; ret = acpi_drv->ops.add(acpi_dev); - if (ret) + if (ret) { + acpi_dev->driver_data = NULL; return ret; + } pr_debug("Driver [%s] successfully bound to device [%s]\n", acpi_drv->name, acpi_dev->pnp.bus_id); -- 2.7.4