From: Kevin Wolf Date: Fri, 4 Apr 2014 15:07:19 +0000 (+0200) Subject: block: Check bdrv_getlength() return value in bdrv_append_temp_snapshot() X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~386^2~42^2~28^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f187743acd39747cc8cc32111518142c924963b9;p=sdk%2Femulator%2Fqemu.git block: Check bdrv_getlength() return value in bdrv_append_temp_snapshot() Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- diff --git a/block.c b/block.c index d89c344a13..990a7542a9 100644 --- a/block.c +++ b/block.c @@ -1184,7 +1184,12 @@ void bdrv_append_temp_snapshot(BlockDriverState *bs, Error **errp) instead of opening 'filename' directly */ /* Get the required size from the image */ - total_size = bdrv_getlength(bs) & BDRV_SECTOR_MASK; + total_size = bdrv_getlength(bs); + if (total_size < 0) { + error_setg_errno(errp, -total_size, "Could not get image size"); + return; + } + total_size &= BDRV_SECTOR_MASK; /* Create the temporary image */ ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));