tree 8a817dfc450af2d2233533dc44593d33e2117eb5
parent 7334571f724df7a19f48cc974e991e00afde1e2f
author Paulo Marques <[EMAIL PROTECTED]> Thu, 31 Mar 2005 08:39:49 -0500
committer Len Brown <[EMAIL PROTECTED]> Tue, 12 Jul 2005 07:58:45 -0400

[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 <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>

 drivers/acpi/video.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -564,12 +564,13 @@ acpi_video_device_find_cap (struct acpi_
                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_
                        }
 out:
                        if (count < 2) {
-                               if (br->levels)
-                                       kfree(br->levels);
+                               kfree(br->levels);
                                kfree(br);
                        } else {
                                br->count = count;
@@ -595,8 +595,7 @@ out:
                }
        }
 
-       if (obj)
-               kfree(obj);
+       kfree(obj);
 
        return_VOID;
 }
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to