Revision c23045de

b/hw/arm/boot.c
237 237
    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
238 238
    if (!filename) {
239 239
        fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
240
        return -1;
240
        goto fail;
241 241
    }
242 242

  
243 243
    fdt = load_device_tree(filename, &size);
244 244
    if (!fdt) {
245 245
        fprintf(stderr, "Couldn't open dtb file %s\n", filename);
246 246
        g_free(filename);
247
        return -1;
247
        goto fail;
248 248
    }
249 249
    g_free(filename);
250 250

  
......
252 252
    scells = qemu_devtree_getprop_cell(fdt, "/", "#size-cells");
253 253
    if (acells == 0 || scells == 0) {
254 254
        fprintf(stderr, "dtb file invalid (#address-cells or #size-cells 0)\n");
255
        return -1;
255
        goto fail;
256 256
    }
257 257

  
258 258
    mem_reg_propsize = acells + scells;
......
264 264
    } else if (hival != 0) {
265 265
        fprintf(stderr, "qemu: dtb file not compatible with "
266 266
                "RAM start address > 4GB\n");
267
        exit(1);
267
        goto fail;
268 268
    }
269 269
    mem_reg_property[acells + scells - 1] = cpu_to_be32(binfo->ram_size);
270 270
    hival = cpu_to_be32(binfo->ram_size >> 32);
......
273 273
    } else if (hival != 0) {
274 274
        fprintf(stderr, "qemu: dtb file not compatible with "
275 275
                "RAM size > 4GB\n");
276
        exit(1);
276
        goto fail;
277 277
    }
278 278

  
279 279
    rc = qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property,
280 280
                              mem_reg_propsize * sizeof(uint32_t));
281 281
    if (rc < 0) {
282 282
        fprintf(stderr, "couldn't set /memory/reg\n");
283
        goto fail;
283 284
    }
284 285

  
285 286
    if (binfo->kernel_cmdline && *binfo->kernel_cmdline) {
......
287 288
                                          binfo->kernel_cmdline);
288 289
        if (rc < 0) {
289 290
            fprintf(stderr, "couldn't set /chosen/bootargs\n");
291
            goto fail;
290 292
        }
291 293
    }
292 294

  
......
295 297
                binfo->initrd_start);
296 298
        if (rc < 0) {
297 299
            fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
300
            goto fail;
298 301
        }
299 302

  
300 303
        rc = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end",
301 304
                    binfo->initrd_start + binfo->initrd_size);
302 305
        if (rc < 0) {
303 306
            fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
307
            goto fail;
304 308
        }
305 309
    }
306 310
    qemu_devtree_dumpdtb(fdt, size);
307 311

  
308 312
    cpu_physical_memory_write(addr, fdt, size);
309 313

  
314
    g_free(fdt);
315

  
310 316
    return 0;
317

  
318
fail:
319
    g_free(fdt);
320
    return -1;
311 321
}
312 322

  
313 323
static void do_cpu_reset(void *opaque)

Also available in: Unified diff