Revision 18cfeb52 hw/qdev.c

b/hw/qdev.c
216 216
    }
217 217
    if (qdev_init(qdev) != 0) {
218 218
        qemu_error("Error initializing device %s\n", driver);
219
        qdev_free(qdev);
220 219
        return NULL;
221 220
    }
222 221
    qdev->opts = opts;
......
232 231

  
233 232
/* Initialize a device.  Device properties should be set before calling
234 233
   this function.  IRQs and MMIO regions should be connected/mapped after
235
   calling this function.  */
234
   calling this function.
235
   On failure, destroy the device and return negative value.
236
   Return 0 on success.  */
236 237
int qdev_init(DeviceState *dev)
237 238
{
238 239
    int rc;
239 240

  
240 241
    assert(dev->state == DEV_STATE_CREATED);
241 242
    rc = dev->info->init(dev, dev->info);
242
    if (rc < 0)
243
    if (rc < 0) {
244
        qdev_free(dev);
243 245
        return rc;
246
    }
244 247
    qemu_register_reset(qdev_reset, dev);
245 248
    if (dev->info->vmsd)
246 249
        vmstate_register(-1, dev->info->vmsd, dev);

Also available in: Unified diff