diff --git a/block.c b/block.c index 6af5f6e39f..53cc9e09c2 100644 --- a/block.c +++ b/block.c @@ -1040,8 +1040,12 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) error_free(local_err); return ret; } - pstrcpy(bs->backing_file, sizeof(bs->backing_file), - bs->backing_hd->file->filename); + + if (bs->backing_hd->file) { + pstrcpy(bs->backing_file, sizeof(bs->backing_file), + bs->backing_hd->file->filename); + } + return 0; }