diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 775ac5d1b..34fa7ad42 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3493,10 +3493,14 @@ out: static int vdev_create(struct scst_dev_type *devt, const char *name, struct scst_vdisk_dev **res_virt_dev) { - int res = 0; + int res; struct scst_vdisk_dev *virt_dev; uint64_t dev_id_num; + res = -EEXIST; + if (vdev_find(name)) + goto out; + virt_dev = kzalloc(sizeof(*virt_dev), GFP_KERNEL); if (virt_dev == NULL) { PRINT_ERROR("Allocation of virtual device %s failed", @@ -3534,6 +3538,7 @@ static int vdev_create(struct scst_dev_type *devt, TRACE_DBG("usn %s", virt_dev->usn); *res_virt_dev = virt_dev; + res = 0; out: return res; @@ -4861,13 +4866,6 @@ static int vdisk_write_proc(char *buffer, char **start, off_t offset, if (action == 1) { /* open */ - if (vdev_find(name)) { - PRINT_ERROR("Virtual device with name " - "%s already exist", name); - res = -EINVAL; - goto out_up; - } - while (isspace(*p) && *p != '\0') p++; filename = p; @@ -5106,14 +5104,6 @@ static int vcdrom_open(char *p, char *name) int res = 0; int cdrom_empty; - virt_dev = vdev_find(name); - if (virt_dev) { - PRINT_ERROR("Virtual device with name " - "%s already exist", name); - res = -EINVAL; - goto out; - } - while (isspace(*p) && *p != '\0') p++; filename = p;