Unchecked blk_getlength() in device models and board code
blk_getlength() can fail. I figure the following need fixing:
hw/arm/musicpal.c: musicpal_init()hw/block/nand.c: nand_realize()hw/block/virtio-blk.c: virtio_blk_update_config()hw/ppc/ppc405_boards.c: taihu_405ep_init()
Quoted 3 lines · Markus Armbruster
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);
}Quoted 1 line
hw/block/virtio-blk.c:virtio_blk_update_config()
Will send a fix.
Quoted 5 lines · Stefan Hajnoczi
Quoted 3 lines · Markus Armbruster
blk_getlength()can fail. I figure the following need fixing:
hw/arm/musicpal.c:musicpal_init()
Quoted 8 lines
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