diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2020-03-17 15:57:41 +0300 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2020-03-17 17:30:03 +0100 |
commit | 709dfb64925ed2b2978bf4c17ab98b2c7a9a05c1 (patch) | |
tree | 0398a1f3045122c77dd5c79d56e9453d7c98f900 /hw/sd/ssi-sd.c | |
parent | 526ab8e8630f17f6f412c160d4e9571766960be9 (diff) | |
download | qemu-709dfb64925ed2b2978bf4c17ab98b2c7a9a05c1.zip qemu-709dfb64925ed2b2978bf4c17ab98b2c7a9a05c1.tar.gz qemu-709dfb64925ed2b2978bf4c17ab98b2c7a9a05c1.tar.bz2 |
hw/sd/ssi-sd: fix error handling in ssi_sd_realize
It's wrong to use same err object as errp parameter for several
function calls without intermediate checking for error: we'll crash if
try to set err object twice. Fix that.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200317125741.15301-1-vsementsov@virtuozzo.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'hw/sd/ssi-sd.c')
-rw-r--r-- | hw/sd/ssi-sd.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c index 91db069..829797b 100644 --- a/hw/sd/ssi-sd.c +++ b/hw/sd/ssi-sd.c @@ -255,13 +255,25 @@ static void ssi_sd_realize(SSISlave *d, Error **errp) carddev = qdev_create(BUS(&s->sdbus), TYPE_SD_CARD); if (dinfo) { qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo), &err); + if (err) { + goto fail; + } } + object_property_set_bool(OBJECT(carddev), true, "spi", &err); + if (err) { + goto fail; + } + object_property_set_bool(OBJECT(carddev), true, "realized", &err); if (err) { - error_setg(errp, "failed to init SD card: %s", error_get_pretty(err)); - return; + goto fail; } + + return; + +fail: + error_propagate_prepend(errp, err, "failed to init SD card: "); } static void ssi_sd_reset(DeviceState *dev) |