Skip to contentSkip to conversation

Unchecked blk_getlength() in device models and board code

Qemu-devel Markus Armbruster 3 participants 3 messages Aug 4, 2017 – Aug 8, 2017

lore
Share & tools
lore
#0 lore raw

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()

#1 lore raw
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.

#2 lore raw
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