Received: from eggs.gnu.org ([2001:4830:134:3::10]:41030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWXaO-000123-6J for qemu-devel@nongnu.org; Wed, 16 Oct 2013 16:20:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWXaJ-0005TM-62 for qemu-devel@nongnu.org; Wed, 16 Oct 2013 16:20:52 -0400 Received: from indium.canonical.com ([91.189.90.7]:54680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWXaH-0005QC-UT for qemu-devel@nongnu.org; Wed, 16 Oct 2013 16:20:46 -0400 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1VWXaG-0008LH-SP for ; Wed, 16 Oct 2013 20:20:44 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id D1E3D2E8080 for ; Wed, 16 Oct 2013 20:20:44 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Date: Wed, 16 Oct 2013 20:10:39 -0000 From: Devin Boyer Sender: bounces@canonical.com References: <20131016191858.16237.90141.malonedeb@soybean.canonical.com> Message-Id: <20131016201039.30749.52459.launchpad@wampee.canonical.com> Errors-To: bounces@canonical.com Subject: [Qemu-devel] [Bug 1240669] Re: sd_init() generates SIGSEGV when passed NULL Reply-To: Bug 1240669 <1240669@bugs.launchpad.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org ** 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=3Dqemu.git;a=3Dcommitdiff;h=3D4f8a066b5fc254eeaabb= bde56ba4f5b29cc68fdf = - See the modifications to sd.c specifically. = + http://git.qemu.org/?p=3Dqemu.git;a=3Dcommitdiff;h=3D4f8a066b5fc254eeaabb= bde56ba4f5b29cc68fdf + See the modifications to sd.c specifically. = When sd_init (sd.c) is called from pl181_init(), bs is potentially null: - s->card =3D sd_init(dinfo ? dinfo->bdrv : NULL, false); = + s->card =3D 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 =3D (SDState *) g_malloc0(sizeof(SDState)); = sd->buf =3D qemu_blockalign(bs, 512); = sd->spi =3D is_spi; = sd->enable =3D 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 S= EGSIGV. + = + int bdrv_is_read_only(BlockDriverState *bs) + { + =C2=A0=C2=A0=C2=A0=C2=A0return bs->read_only; + } = Checking out tag v1.6.1 reverted the problem. Thanks! -- = You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1240669 Title: sd_init() generates SIGSEGV when passed NULL Status in QEMU: New Bug description: Ran into a bug following the following tutorial: 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=3Dqemu.git;a=3Dcommitdiff;h=3D4f8a066b5fc254eeaabb= bde56ba4f5b29cc68fdf See the modifications to sd.c specifically. When sd_init (sd.c) is called from pl181_init(), bs is potentially null: s->card =3D sd_init(dinfo ? dinfo->bdrv : NULL, false); 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 =3D (SDState *) g_malloc0(sizeof(SDState)); = sd->buf =3D qemu_blockalign(bs, 512); = sd->spi =3D is_spi; = sd->enable =3D 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 S= EGSIGV. int bdrv_is_read_only(BlockDriverState *bs) { =C2=A0=C2=A0=C2=A0=C2=A0return bs->read_only; } Checking out tag v1.6.1 reverted the problem. Thanks! To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1240669/+subscriptions