diff options
author | Yu, Luming <luming.yu@intel.com> | 2006-04-27 05:25:00 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2006-05-15 02:05:48 -0400 |
commit | 973bf491a55b825740f0d8d300b50bcd3d6fb8de (patch) | |
tree | c01d8e5ff13020dfffe6d99248820f0a737eba4c | |
parent | d8c3291c73b958243b33f8509d4507e76dafd055 (diff) |
ACPI: fix potential memory leaks in driver/acpi/video.c
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" <luming.yu@intel.com>
Signed-off-by: Vasily Averin <vvs@sw.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | drivers/acpi/video.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index bd4887518373..fcefcb104b31 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -1294,7 +1294,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
1294 | struct acpi_video_bus *video) | 1294 | struct acpi_video_bus *video) |
1295 | { | 1295 | { |
1296 | unsigned long device_id; | 1296 | unsigned long device_id; |
1297 | int status, result; | 1297 | int status; |
1298 | struct acpi_video_device *data; | 1298 | struct acpi_video_device *data; |
1299 | 1299 | ||
1300 | ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device"); | 1300 | ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device"); |
@@ -1346,8 +1346,11 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
1346 | if (ACPI_FAILURE(status)) { | 1346 | if (ACPI_FAILURE(status)) { |
1347 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1347 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
1348 | "Error installing notify handler\n")); | 1348 | "Error installing notify handler\n")); |
1349 | result = -ENODEV; | 1349 | if(data->brightness) |
1350 | goto end; | 1350 | kfree(data->brightness->levels); |
1351 | kfree(data->brightness); | ||
1352 | kfree(data); | ||
1353 | return -ENODEV; | ||
1351 | } | 1354 | } |
1352 | 1355 | ||
1353 | down(&video->sem); | 1356 | down(&video->sem); |
@@ -1359,7 +1362,6 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
1359 | return_VALUE(0); | 1362 | return_VALUE(0); |
1360 | } | 1363 | } |
1361 | 1364 | ||
1362 | end: | ||
1363 | return_VALUE(-ENOENT); | 1365 | return_VALUE(-ENOENT); |
1364 | } | 1366 | } |
1365 | 1367 | ||
@@ -1643,8 +1645,9 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video) | |||
1643 | printk(KERN_WARNING PREFIX | 1645 | printk(KERN_WARNING PREFIX |
1644 | "hhuuhhuu bug in acpi video driver.\n"); | 1646 | "hhuuhhuu bug in acpi video driver.\n"); |
1645 | 1647 | ||
1648 | if (data->brightness); | ||
1649 | kfree(data->brightness->levels); | ||
1646 | kfree(data->brightness); | 1650 | kfree(data->brightness); |
1647 | |||
1648 | kfree(data); | 1651 | kfree(data); |
1649 | } | 1652 | } |
1650 | 1653 | ||
@@ -1785,6 +1788,10 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
1785 | if (ACPI_FAILURE(status)) { | 1788 | if (ACPI_FAILURE(status)) { |
1786 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1789 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
1787 | "Error installing notify handler\n")); | 1790 | "Error installing notify handler\n")); |
1791 | acpi_video_bus_stop_devices(video); | ||
1792 | acpi_video_bus_put_devices(video); | ||
1793 | kfree(video->attached_array); | ||
1794 | acpi_video_bus_remove_fs(device); | ||
1788 | result = -ENODEV; | 1795 | result = -ENODEV; |
1789 | goto end; | 1796 | goto end; |
1790 | } | 1797 | } |
@@ -1796,10 +1803,8 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
1796 | video->flags.post ? "yes" : "no"); | 1803 | video->flags.post ? "yes" : "no"); |
1797 | 1804 | ||
1798 | end: | 1805 | end: |
1799 | if (result) { | 1806 | if (result) |
1800 | acpi_video_bus_remove_fs(device); | ||
1801 | kfree(video); | 1807 | kfree(video); |
1802 | } | ||
1803 | 1808 | ||
1804 | return_VALUE(result); | 1809 | return_VALUE(result); |
1805 | } | 1810 | } |