From: Stefan Weil <sw@weilnetz.de>
To: Bug 1240669 <1240669@bugs.launchpad.net>,
qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>
Subject: Re: [Qemu-devel] [Bug 1240669] Re: sd_init() generates SIGSEGV when passed NULL
Date: Thu, 17 Oct 2013 07:09:52 +0200 [thread overview]
Message-ID: <525F7120.8030102@weilnetz.de> (raw)
In-Reply-To: <20131016201039.30749.52459.launchpad@wampee.canonical.com>
Am 16.10.2013 22:10, schrieb Devin Boyer:
> ** Description changed:
>
> Ran into a bug following the following tutorial:
> - http://balau82.wordpress.com/2010/03/10/u-boot-for-arm-on-qemu/
> + http://balau82.wordpress.com/2010/03/10/u-boot-for-arm-on-qemu/
>
> I built QEMU from a clone of master and became stuck at the beginning
> part of the tutorial where only u-boot.bin is exectuted.
>
> - http://git.qemu.org/?p=qemu.git;a=commitdiff;h=4f8a066b5fc254eeaabbbde56ba4f5b29cc68fdf
> - See the modifications to sd.c specifically.
> + http://git.qemu.org/?p=qemu.git;a=commitdiff;h=4f8a066b5fc254eeaabbbde56ba4f5b29cc68fdf
> + See the modifications to sd.c specifically.
>
> When sd_init (sd.c) is called from pl181_init(), bs is potentially null:
> - s->card = sd_init(dinfo ? dinfo->bdrv : NULL, false);
> + s->card = sd_init(dinfo ? dinfo->bdrv : NULL, false);
>
> - sd_init() :
> + sd_init():
> +
> SDState *sd_init(BlockDriverState *bs, bool is_spi)
> {
> SDState *sd;
> +
> + if (bdrv_is_read_only(bs)) {
> + fprintf(stderr, "sd_init: Cannot use read-only drive\n");
> + return NULL;
> + }
>
> sd = (SDState *) g_malloc0(sizeof(SDState));
> sd->buf = qemu_blockalign(bs, 512);
> sd->spi = is_spi;
> sd->enable = true;
> sd_reset(sd, bs);
> if (sd->bdrv) {
> bdrv_attach_dev_nofail(sd->bdrv, sd);
> bdrv_set_dev_ops(sd->bdrv, &sd_block_ops, sd);
> }
> vmstate_register(NULL, -1, &sd_vmstate, sd);
> return sd;
> }
>
> - Line 497 calls bdrv_is_read_only(bs) (from block.c)and this generates a
> - SEGSIGV.
>
> - int bdrv_is_read_only(BlockDriverState *bs)
> - {
> - return bs->read_only;
> - }
> + Line 497 calls bdrv_is_read_only(bs) (from block.c)and this generates a SEGSIGV.
> +
> + int bdrv_is_read_only(BlockDriverState *bs)
> + {
> + return bs->read_only;
> + }
>
> Checking out tag v1.6.1 reverted the problem. Thanks!
>
See http://lists.nongnu.org/archive/html/qemu-devel/2013-10/msg02075.html
for a possible fix.
Regards,
SW
next prev parent reply other threads:[~2013-10-17 5:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-16 19:18 [Qemu-devel] [Bug 1240669] [NEW] sd_init() generates SIGSEGV when passed NULL Devin Boyer
2013-10-16 20:10 ` [Qemu-devel] [Bug 1240669] " Devin Boyer
2013-10-17 5:09 ` Stefan Weil [this message]
2013-10-22 1:23 ` Devin Boyer
2016-06-28 14:43 ` T. Huth
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=525F7120.8030102@weilnetz.de \
--to=sw@weilnetz.de \
--cc=1240669@bugs.launchpad.net \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.