aboutsummaryrefslogtreecommitdiff
path: root/block/qed.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-10-31 10:23:15 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2011-10-31 10:23:15 -0500
commit3a069ff11b9178a84f560435b2fd22294d839018 (patch)
treea5ffe92f5909b26fc77af69d7f5e05f1e20fe268 /block/qed.c
parentacba391493badb972db654fa1299052fce0379a3 (diff)
parent3899edf7e4a13439793aaad21a17863a3b9152c2 (diff)
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
Diffstat (limited to 'block/qed.c')
-rw-r--r--block/qed.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/block/qed.c b/block/qed.c
index 2e06992784..d032a4574c 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -388,7 +388,6 @@ static int bdrv_qed_open(BlockDriverState *bs, int flags)
if (ret < 0) {
return ret;
}
- ret = 0; /* ret should always be 0 or -errno */
qed_header_le_to_cpu(&le_header, &s->header);
if (s->header.magic != QED_MAGIC) {
@@ -1420,8 +1419,10 @@ static int bdrv_qed_change_backing_file(BlockDriverState *bs,
memcpy(buffer, &le_header, sizeof(le_header));
buffer_len = sizeof(le_header);
- memcpy(buffer + buffer_len, backing_file, backing_file_len);
- buffer_len += backing_file_len;
+ if (backing_file) {
+ memcpy(buffer + buffer_len, backing_file, backing_file_len);
+ buffer_len += backing_file_len;
+ }
/* Write new header */
ret = bdrv_pwrite_sync(bs->file, 0, buffer, buffer_len);