Skip to content

Commit

Permalink
ACPI: bus: Set driver_data to NULL every time .add() fails
Browse files Browse the repository at this point in the history
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 <michal.wilczynski@intel.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
mwilczy authored and rafaeljw committed Jul 14, 2023
1 parent c542ce3 commit 0d16710
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/acpi/bus.c
Expand Up @@ -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);
Expand Down

0 comments on commit 0d16710

Please sign in to comment.