goto free_device;
goto put_fd;
static int tgt_device_create(int tid, uint64_t dev_id, char *device_type,			     int fd, unsigned long dflags){	struct tgt_target *target;	struct tgt_device *device;	unsigned long flags;	dprintk("tid %d dev_id %llu type %s fd %d\n",		tid, dev_id, device_type, fd);	target = target_find(tid);	if (!target)		return -EINVAL;	device = kmalloc(sizeof(*device), GFP_KERNEL);	if (!device)		return -ENOMEM;	memset(device, 0, sizeof(*device));	device->dev_id = dev_id;	device->target = target;	device->fd = fd;	device->dt = device_template_get(device_type);	if (!device->dt) {		eprintk("Could not get devive type %s\n", device_type);		goto free_device;	}	device->dt_data = kmalloc(device->dt->priv_data_size,				  GFP_KERNEL);	if (!device->dt_data)		goto put_template;	if (device->dt->create)		if (device->dt->create(device))			goto free_priv_dt_data;	if (tgt_sysfs_register_device(device))		goto dt_destroy;	spin_lock_irqsave(&target->lock, flags);	list_add(&device->dlist, &target->device_list);	spin_unlock_irqrestore(&target->lock, flags);	return 0;dt_destroy:	if (device->dt->destroy)		device->dt->destroy(device);free_priv_dt_data:	kfree(device->dt_data);put_template:	device_template_put(device->dt);free_device:	kfree(device);	return -EINVAL;}