summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-05-21 16:09:35 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-05-25 16:43:52 +0200
commitaad090a11389e17cacfbda62b963ddf709e5cc34 (patch)
treef2e0a106c071872a3a3843650a20f523f9b0ad00
parent73ae2b1f395802d78929df2f1f1da301468f6df3 (diff)
ACPI: video: Use devm action for video bus object cleanup
Introduce acpi_video_bus_free() for freeing video bus object memory and reversing changes related to it made during ACPI video bus device probe, modify acpi_video_bus_probe() to add acpi_video_bus_free() as a devm action, and remove the code superseded by it from acpi_video_bus_remove(). No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/3892168.MHq7AAxBmi@rafael.j.wysocki
-rw-r--r--drivers/acpi/acpi_video.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index ca2bee967946..11dd00614f6b 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1953,6 +1953,14 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
return 0;
}
+static void acpi_video_bus_free(void *data)
+{
+ struct acpi_video_bus *video = data;
+
+ video->device->driver_data = NULL;
+ kfree(video);
+}
+
static int duplicate_dev_check(struct device *sibling, void *data)
{
struct acpi_video_bus *video;
@@ -2005,6 +2013,10 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
video->device = device;
device->driver_data = video;
+ error = devm_add_action_or_reset(dev, acpi_video_bus_free, video);
+ if (error)
+ return error;
+
/*
* A hack to fix the duplicate name "VID" problem on T61 and the
* duplicate name "VGA" problem on Pa 3553.
@@ -2022,7 +2034,7 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
acpi_video_bus_find_cap(video);
error = acpi_video_bus_check(video);
if (error)
- goto err_free_video;
+ return error;
mutex_init(&video->device_list_lock);
INIT_LIST_HEAD(&video->video_device_list);
@@ -2081,9 +2093,6 @@ err_del:
err_put_video:
acpi_video_bus_put_devices(video);
kfree(video->attached_array);
-err_free_video:
- kfree(video);
- device->driver_data = NULL;
return error;
}
@@ -2104,9 +2113,6 @@ static void acpi_video_bus_remove(struct auxiliary_device *aux_dev)
acpi_video_bus_unregister_backlight(video);
acpi_video_bus_put_devices(video);
kfree(video->attached_array);
-
- kfree(video);
- device->driver_data = NULL;
}
static int __init is_i740(struct pci_dev *dev)