[PATCH 2.6.25.stable] - Kernel

This is a discussion on [PATCH 2.6.25.stable] - Kernel ; From: Julia Jomantaite Thanks to Arjan for spotting this for .stable: http://www.kerneloops.org/search.php...tch_brightness upstream commit 469778c1740fcf3113498b6fdf4559bdec25c58f ACPI: video: fix brightness allocation Fix use of uninitialized device->brightness. Signed-off-by: Julia Jomantaite Signed-off-by: Andi Kleen Acked-by: Zhang Rui Signed-off-by: Len Brown --- in addition ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [PATCH 2.6.25.stable]

  1. [PATCH 2.6.25.stable]

    From: Julia Jomantaite

    Thanks to Arjan for spotting this for .stable:
    http://www.kerneloops.org/search.php...tch_brightness

    upstream commit 469778c1740fcf3113498b6fdf4559bdec25c58f

    ACPI: video: fix brightness allocation

    Fix use of uninitialized device->brightness.

    Signed-off-by: Julia Jomantaite
    Signed-off-by: Andi Kleen
    Acked-by: Zhang Rui
    Signed-off-by: Len Brown

    ---
    in addition to the 2.6.26.stable patch i sent a moment ago,
    here is a version refreshed against 2.6.25.stable

    Index: linux-2.6.26.y/drivers/acpi/video.c
    ================================================== =================
    --- linux-2.6.26.y.orig/drivers/acpi/video.c
    +++ linux-2.6.26.y/drivers/acpi/video.c
    @@ -631,6 +631,76 @@ acpi_video_bus_DOS(struct acpi_video_bus
    * device : video output device (LCD, CRT, ..)
    *
    * Return Value:
    + * Maximum brightness level
    + *
    + * Allocate and initialize device->brightness.
    + */
    +
    +static int
    +acpi_video_init_brightness(struct acpi_video_device *device)
    +{
    + union acpi_object *obj = NULL;
    + int i, max_level = 0, count = 0;
    + union acpi_object *o;
    + struct acpi_video_device_brightness *br = NULL;
    +
    + if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels( device, &obj))) {
    + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available "
    + "LCD brightness level\n"));
    + goto out;
    + }
    +
    + if (obj->package.count < 2)
    + goto out;
    +
    + br = kzalloc(sizeof(*br), GFP_KERNEL);
    + if (!br) {
    + printk(KERN_ERR "can't allocate memory\n");
    + goto out;
    + }
    +
    + br->levels = kmalloc(obj->package.count * sizeof *(br->levels),
    + GFP_KERNEL);
    + if (!br->levels)
    + goto out_free;
    +
    + for (i = 0; i < obj->package.count; i++) {
    + o = (union acpi_object *)&obj->package.elements[i];
    + if (o->type != ACPI_TYPE_INTEGER) {
    + printk(KERN_ERR PREFIX "Invalid data\n");
    + continue;
    + }
    + br->levels[count] = (u32) o->integer.value;
    +
    + if (br->levels[count] > max_level)
    + max_level = br->levels[count];
    + count++;
    + }
    +
    + if (count < 2)
    + goto out_free_levels;
    +
    + br->count = count;
    + device->brightness = br;
    + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "found %d brightness levels\n", count));
    + kfree(obj);
    + return max_level;
    +
    +out_free_levels:
    + kfree(br->levels);
    +out_free:
    + kfree(br);
    +out:
    + device->brightness = NULL;
    + kfree(obj);
    + return 0;
    +}
    +
    +/*
    + * Arg:
    + * device : video output device (LCD, CRT, ..)
    + *
    + * Return Value:
    * None
    *
    * Find out all required AML methods defined under the output
    @@ -640,10 +710,7 @@ acpi_video_bus_DOS(struct acpi_video_bus
    static void acpi_video_device_find_cap(struct acpi_video_device *device)
    {
    acpi_handle h_dummy1;
    - int i;
    u32 max_level = 0;
    - union acpi_object *obj = NULL;
    - struct acpi_video_device_brightness *br = NULL;


    memset(&device->cap, 0, sizeof(device->cap));
    @@ -672,53 +739,7 @@ static void acpi_video_device_find_cap(s
    device->cap._DSS = 1;
    }

    - if (ACPI_SUCCESS(acpi_video_device_lcd_query_levels(d evice, &obj))) {
    -
    - if (obj->package.count >= 2) {
    - int count = 0;
    - union acpi_object *o;
    -
    - br = kzalloc(sizeof(*br), GFP_KERNEL);
    - if (!br) {
    - printk(KERN_ERR "can't allocate memory\n");
    - } else {
    - br->levels = kmalloc(obj->package.count *
    - sizeof *(br->levels), GFP_KERNEL);
    - if (!br->levels)
    - goto out;
    -
    - for (i = 0; i < obj->package.count; i++) {
    - o = (union acpi_object *)&obj->package.
    - elements[i];
    - if (o->type != ACPI_TYPE_INTEGER) {
    - printk(KERN_ERR PREFIX "Invalid data\n");
    - continue;
    - }
    - br->levels[count] = (u32) o->integer.value;
    -
    - if (br->levels[count] > max_level)
    - max_level = br->levels[count];
    - count++;
    - }
    - out:
    - if (count < 2) {
    - kfree(br->levels);
    - kfree(br);
    - } else {
    - br->count = count;
    - device->brightness = br;
    - ACPI_DEBUG_PRINT((ACPI_DB_INFO,
    - "found %d brightness levels\n",
    - count));
    - }
    - }
    - }
    -
    - } else {
    - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available LCD brightness level\n"));
    - }
    -
    - kfree(obj);
    + max_level = acpi_video_init_brightness(device);

    if (device->cap._BCL && device->cap._BCM && max_level > 0) {
    int result;
    @@ -1705,6 +1726,8 @@ static void
    acpi_video_switch_brightness(struct acpi_video_device *device, int event)
    {
    unsigned long level_current, level_next;
    + if (!device->brightness)
    + return;
    acpi_video_device_lcd_get_level_current(device, &level_current);
    level_next = acpi_video_get_next_level(device, level_current, event);
    acpi_video_device_lcd_set_level(device, level_next);
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. patch acpi-video-fix-brightness-allocation.patch added to 2.6.25-stable tree


    This is a note to let you know that we have just queued up the patch titled

    Subject: ACPI: video: fix brightness allocation

    to the 2.6.25-stable tree. Its filename is

    acpi-video-fix-brightness-allocation.patch

    A git repo of this tree can be found at
    http://www.kernel.org/git/?p=linux/k....git;a=summary


    From lenb@kernel.org Fri Nov 7 14:36:23 2008
    From: Julia Jomantaite
    Date: Mon, 27 Oct 2008 23:50:57 -0400 (EDT)
    Subject: ACPI: video: fix brightness allocation
    To: stable@kernel.org
    Cc: Julia Jomantaite , linux-acpi@vger.kernel.org, Linux Kernel Mailing List , Arjan van de Ven
    Message-ID:


    From: Julia Jomantaite

    Thanks to Arjan for spotting this for .stable:
    http://www.kerneloops.org/search.php...tch_brightness

    upstream commit 469778c1740fcf3113498b6fdf4559bdec25c58f

    ACPI: video: fix brightness allocation

    Fix use of uninitialized device->brightness.

    Signed-off-by: Julia Jomantaite
    Signed-off-by: Andi Kleen
    Acked-by: Zhang Rui
    Signed-off-by: Len Brown
    Signed-off-by: Greg Kroah-Hartman

    ---
    drivers/acpi/video.c | 123 ++++++++++++++++++++++++++++++---------------------
    1 file changed, 73 insertions(+), 50 deletions(-)

    --- a/drivers/acpi/video.c
    +++ b/drivers/acpi/video.c
    @@ -624,6 +624,76 @@ acpi_video_bus_DOS(struct acpi_video_bus
    * device : video output device (LCD, CRT, ..)
    *
    * Return Value:
    + * Maximum brightness level
    + *
    + * Allocate and initialize device->brightness.
    + */
    +
    +static int
    +acpi_video_init_brightness(struct acpi_video_device *device)
    +{
    + union acpi_object *obj = NULL;
    + int i, max_level = 0, count = 0;
    + union acpi_object *o;
    + struct acpi_video_device_brightness *br = NULL;
    +
    + if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels( device, &obj))) {
    + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available "
    + "LCD brightness level\n"));
    + goto out;
    + }
    +
    + if (obj->package.count < 2)
    + goto out;
    +
    + br = kzalloc(sizeof(*br), GFP_KERNEL);
    + if (!br) {
    + printk(KERN_ERR "can't allocate memory\n");
    + goto out;
    + }
    +
    + br->levels = kmalloc(obj->package.count * sizeof *(br->levels),
    + GFP_KERNEL);
    + if (!br->levels)
    + goto out_free;
    +
    + for (i = 0; i < obj->package.count; i++) {
    + o = (union acpi_object *)&obj->package.elements[i];
    + if (o->type != ACPI_TYPE_INTEGER) {
    + printk(KERN_ERR PREFIX "Invalid data\n");
    + continue;
    + }
    + br->levels[count] = (u32) o->integer.value;
    +
    + if (br->levels[count] > max_level)
    + max_level = br->levels[count];
    + count++;
    + }
    +
    + if (count < 2)
    + goto out_free_levels;
    +
    + br->count = count;
    + device->brightness = br;
    + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "found %d brightness levels\n", count));
    + kfree(obj);
    + return max_level;
    +
    +out_free_levels:
    + kfree(br->levels);
    +out_free:
    + kfree(br);
    +out:
    + device->brightness = NULL;
    + kfree(obj);
    + return 0;
    +}
    +
    +/*
    + * Arg:
    + * device : video output device (LCD, CRT, ..)
    + *
    + * Return Value:
    * None
    *
    * Find out all required AML methods defined under the output
    @@ -633,10 +703,7 @@ acpi_video_bus_DOS(struct acpi_video_bus
    static void acpi_video_device_find_cap(struct acpi_video_device *device)
    {
    acpi_handle h_dummy1;
    - int i;
    u32 max_level = 0;
    - union acpi_object *obj = NULL;
    - struct acpi_video_device_brightness *br = NULL;


    memset(&device->cap, 0, sizeof(device->cap));
    @@ -665,53 +732,7 @@ static void acpi_video_device_find_cap(s
    device->cap._DSS = 1;
    }

    - if (ACPI_SUCCESS(acpi_video_device_lcd_query_levels(d evice, &obj))) {
    -
    - if (obj->package.count >= 2) {
    - int count = 0;
    - union acpi_object *o;
    -
    - br = kzalloc(sizeof(*br), GFP_KERNEL);
    - if (!br) {
    - printk(KERN_ERR "can't allocate memory\n");
    - } else {
    - br->levels = kmalloc(obj->package.count *
    - sizeof *(br->levels), GFP_KERNEL);
    - if (!br->levels)
    - goto out;
    -
    - for (i = 0; i < obj->package.count; i++) {
    - o = (union acpi_object *)&obj->package.
    - elements[i];
    - if (o->type != ACPI_TYPE_INTEGER) {
    - printk(KERN_ERR PREFIX "Invalid data\n");
    - continue;
    - }
    - br->levels[count] = (u32) o->integer.value;
    -
    - if (br->levels[count] > max_level)
    - max_level = br->levels[count];
    - count++;
    - }
    - out:
    - if (count < 2) {
    - kfree(br->levels);
    - kfree(br);
    - } else {
    - br->count = count;
    - device->brightness = br;
    - ACPI_DEBUG_PRINT((ACPI_DB_INFO,
    - "found %d brightness levels\n",
    - count));
    - }
    - }
    - }
    -
    - } else {
    - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available LCD brightness level\n"));
    - }
    -
    - kfree(obj);
    + max_level = acpi_video_init_brightness(device);

    if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){
    int result;
    @@ -1710,6 +1731,8 @@ static void
    acpi_video_switch_brightness(struct acpi_video_device *device, int event)
    {
    unsigned long level_current, level_next;
    + if (!device->brightness)
    + return;
    acpi_video_device_lcd_get_level_current(device, &level_current);
    level_next = acpi_video_get_next_level(device, level_current, event);
    acpi_video_device_lcd_set_level(device, level_next);


    Patches currently in stable-queue which might be from julia.jomantaite@gmail.com are

    queue-2.6.25/acpi-video-fix-brightness-allocation.patch
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread