Revision 6987307c

b/block.c
428 428
            drv = find_image_format(filename);
429 429
        }
430 430
    }
431

  
431 432
    if (!drv) {
432 433
        ret = -ENOENT;
433 434
        goto unlink_and_fail;
434 435
    }
436
    if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
437
        ret = -ENOTSUP;
438
        goto unlink_and_fail;
439
    }
440

  
435 441
    bs->drv = drv;
436 442
    bs->opaque = qemu_mallocz(drv->instance_size);
437 443

  
......
453 459
    } else {
454 460
        open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
455 461
    }
456
    if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
457
        ret = -ENOTSUP;
458
    } else {
459
        ret = drv->bdrv_open(bs, filename, open_flags);
460
    }
462

  
463
    ret = drv->bdrv_open(bs, filename, open_flags);
461 464
    if (ret < 0) {
462
        qemu_free(bs->opaque);
463
        bs->opaque = NULL;
464
        bs->drv = NULL;
465
    unlink_and_fail:
466
        if (bs->is_temporary)
467
            unlink(filename);
468
        return ret;
465
        goto free_and_fail;
469 466
    }
467

  
470 468
    if (drv->bdrv_getlength) {
471 469
        bs->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
472 470
    }
......
499 497
            bs->change_cb(bs->change_opaque);
500 498
    }
501 499
    return 0;
500

  
501
free_and_fail:
502
    qemu_free(bs->opaque);
503
    bs->opaque = NULL;
504
    bs->drv = NULL;
505
unlink_and_fail:
506
    if (bs->is_temporary)
507
        unlink(filename);
508
    return ret;
502 509
}
503 510

  
504 511
void bdrv_close(BlockDriverState *bs)

Also available in: Unified diff