qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/4] hw/misc/bcm2835_property: Fix handling of FRAMEBUFFER_SE


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 1/4] hw/misc/bcm2835_property: Fix handling of FRAMEBUFFER_SET_PALETTE
Date: Thu, 25 Jul 2024 13:49:55 +0200
User-agent: Mozilla Thunderbird

On 23/7/24 15:10, Peter Maydell wrote:
The documentation of the "Set palette" mailbox property at
https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface#set-palette
says it has the form:

     Length: 24..1032
     Value:
         u32: offset: first palette index to set (0-255)
         u32: length: number of palette entries to set (1-256)
         u32...: RGBA palette values (offset to offset+length-1)

We get this wrong in a couple of ways:
  * we aren't checking the offset and length are in range, so the guest
    can make us spin for a long time by providing a large length
  * the bounds check on our loop is wrong: we should iterate through
    'length' palette entries, not 'length - offset' entries

Fix the loop to implement the bounds checks and get the loop
condition right. In the process, make the variables local to
this switch case, rather than function-global, so it's clearer
what type they are when reading the code.

Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
  hw/misc/bcm2835_property.c | 27 ++++++++++++++++-----------
  1 file changed, 16 insertions(+), 11 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]