提交 d1dd0c23 编写于 作者: P Paulo Marques 提交者: Len Brown

[ACPI] fix kmalloc size bug in acpi/video.c

acpi_video_device_find_cap() used &p instead of *p
when calculating storage size, thus allocating
only 4 or 8 bytes instead of 12...

Also, kfree(NULL) is legal, so remove some unneeded checks.

From: Paulo Marques <pmarques@grupopie.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 7334571f
......@@ -564,12 +564,13 @@ acpi_video_device_find_cap (struct acpi_video_device *device)
int count = 0;
union acpi_object *o;
br = kmalloc(sizeof &br, GFP_KERNEL);
br = kmalloc(sizeof(*br), GFP_KERNEL);
if (!br) {
printk(KERN_ERR "can't allocate memory\n");
} else {
memset(br, 0, sizeof &br);
br->levels = kmalloc(obj->package.count * sizeof &br->levels, GFP_KERNEL);
memset(br, 0, sizeof(*br));
br->levels = kmalloc(obj->package.count *
sizeof *(br->levels), GFP_KERNEL);
if (!br->levels)
goto out;
......@@ -584,8 +585,7 @@ acpi_video_device_find_cap (struct acpi_video_device *device)
}
out:
if (count < 2) {
if (br->levels)
kfree(br->levels);
kfree(br->levels);
kfree(br);
} else {
br->count = count;
......@@ -595,8 +595,7 @@ acpi_video_device_find_cap (struct acpi_video_device *device)
}
}
if (obj)
kfree(obj);
kfree(obj);
return_VOID;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册