diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2015-04-15 10:43:44 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2015-04-28 15:36:09 +0200 |
commit | c485cf9c9277ca9b3d5227c99a13c374e812f42b (patch) | |
tree | ff8f732cc74598d2639713fda1a3a0f896f65f81 /hw | |
parent | d07063e46047242c4f010ff9ddbff5e02f15d9e7 (diff) | |
download | qemu-c485cf9c9277ca9b3d5227c99a13c374e812f42b.zip qemu-c485cf9c9277ca9b3d5227c99a13c374e812f42b.tar.gz qemu-c485cf9c9277ca9b3d5227c99a13c374e812f42b.tar.bz2 |
m25p80: fix s->blk usage before assignment
Delay the call to blk_blockalign() until s->blk has been assigned.
This never caused a crash because blk_blockalign(NULL, size) defaults to
4096 alignment but it's technically incorrect.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1429091024-25098-1-git-send-email-stefanha@redhat.com
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/block/m25p80.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 728e384..efc43dd 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -621,7 +621,6 @@ static int m25p80_init(SSISlave *ss) s->size = s->pi->sector_size * s->pi->n_sectors; s->dirty_page = -1; - s->storage = blk_blockalign(s->blk, s->size); /* FIXME use a qdev drive property instead of drive_get_next() */ dinfo = drive_get_next(IF_MTD); @@ -631,6 +630,8 @@ static int m25p80_init(SSISlave *ss) s->blk = blk_by_legacy_dinfo(dinfo); blk_attach_dev_nofail(s->blk, s); + s->storage = blk_blockalign(s->blk, s->size); + /* FIXME: Move to late init */ if (blk_read(s->blk, 0, s->storage, DIV_ROUND_UP(s->size, BDRV_SECTOR_SIZE))) { @@ -639,6 +640,7 @@ static int m25p80_init(SSISlave *ss) } } else { DB_PRINT_L(0, "No BDRV - binding to RAM\n"); + s->storage = blk_blockalign(NULL, s->size); memset(s->storage, 0xFF, s->size); } |