From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Subject: Re: [Qemu-devel] [PATCH for-2.4] m25p80: fix s->blk usage before assignment
Date: Wed, 15 Apr 2015 11:53:00 +0200 [thread overview]
Message-ID: <552E34FC.20808@redhat.com> (raw)
In-Reply-To: <1429091024-25098-1-git-send-email-stefanha@redhat.com>
On 15/04/2015 11:43, Stefan Hajnoczi wrote:
> 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>
> ---
> hw/block/m25p80.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index afe243b..d6a37a5 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);
> @@ -629,6 +628,7 @@ static int m25p80_init(SSISlave *ss)
> if (dinfo) {
> DB_PRINT_L(0, "Binding to IF_MTD drive\n");
> s->blk = blk_by_legacy_dinfo(dinfo);
> + s->storage = blk_blockalign(s->blk, s->size);
>
> /* FIXME: Move to late init */
> if (blk_read(s->blk, 0, s->storage,
> @@ -638,6 +638,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);
> }
>
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2015-04-15 9:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-15 9:43 [Qemu-devel] [PATCH for-2.4] m25p80: fix s->blk usage before assignment Stefan Hajnoczi
2015-04-15 9:53 ` Paolo Bonzini [this message]
2015-04-21 13:20 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=552E34FC.20808@redhat.com \
--to=pbonzini@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).