memory leakages in driver/acpi/video.c
PATCH 14/16 memory leakages in driver/acpi/video.c
From: "Yu, Luming" <[email protected]>
acpi_video_bus_get_one_device() and other functions in driver/acpi/video.c do not release allocated memory on remove and on the error path.
Signed-off-by "Yu, Luming" <[email protected]>
Signed-off-by Vasily Averin <[email protected]>
Cc "Brown, Len" <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
drivers/acpi/video.c | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-)
drivers/acpi/video.c renamed from drivers/acpi/video.c~fw-memory-leakages-in-driver-acpi-videoc +13 -8
@@ -1284,7 +1284,7 @@ acpi_video_bus_get_one_device(struct acp struct acpi_video_bus *video) {unsigned long device_id; -int status, result; +int status;struct acpi_video_device *data;ACPI_FUNCTION_TRACE ("acpi_video_bus_get_one_device" );
@@ -1334,8 +1334,11 @@ acpi_video_bus_get_one_device(struct acp acpi_video_device_notify, data);if (ACPI_FAILURE (status)) { - result = -ENODEV ; - goto end; +if (data->brightness) +kfree (data->brightness->levels); +kfree (data->brightness); +kfree (data); +return_VALUE (-ENODEV ); }down (&video->sem);
@@ -1347,7 +1350,6 @@ acpi_video_bus_get_one_device(struct acpreturn_VALUE (0 ); } - end:return_VALUE (-ENOENT ); }
@@ -1626,8 +1628,9 @@ static int acpi_video_bus_put_devices(st printk(KERN_WARNING PREFIX "hhuuhhuu bug in acpi video driver.\n"); +if (data->brightness); +kfree (data->brightness->levels);kfree (data->brightness); -kfree (data); }
@@ -1766,6 +1769,10 @@ static int acpi_video_bus_add(struct acpACPI_DEVICE_NOTIFY , acpi_video_bus_notify, video);if (ACPI_FAILURE (status)) { +acpi_video_bus_stop_devices (video); +acpi_video_bus_put_devices (video); +kfree (video->attached_array); +acpi_video_bus_remove_fs (device); result = -ENODEV ; goto end; }
@@ -1777,10 +1784,8 @@ static int acpi_video_bus_add(struct acp video->flags.post ? "yes" : "no"); end: -if (result) { -acpi_video_bus_remove_fs (device); +if (result)kfree (video); - }return_VALUE (result); }
_