qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [Qemu-devel] Unchecked blk_getlength() in device models


From: Peter Maydell
Subject: Re: [Qemu-block] [Qemu-devel] Unchecked blk_getlength() in device models and board code
Date: Tue, 8 Aug 2017 13:11:04 +0100

On 8 August 2017 at 13:04, Stefan Hajnoczi <address@hidden> wrote:
> On Fri, Aug 04, 2017 at 04:01:18PM +0200, Markus Armbruster wrote:
>> blk_getlength() can fail.  I figure the following need fixing:
>>
>> hw/arm/musicpal.c: musicpal_init()
>
> Seems okay:
>
> flash_size = blk_getlength(blk);
> if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
>     flash_size != 32*1024*1024) {
>     fprintf(stderr, "Invalid flash image size\n");
>     exit(1);
> }

A lot of the time for flash devices it's not possible to
get an error code out of blk_getlength() anyway, because
AFAIK it only happens for cases like "cdrom with CD
ejected" and "sd card emulating the card-ejected state".
Still better to handle the error value than not, though.

thanks
-- PMM



reply via email to

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