diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index a9d0ba2ca..eb9facb32 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1006,19 +1006,21 @@ static int scst_process_tgt_enable_store(struct scst_tgt *tgt, bool enable) TRACE_DBG("tgt %s, enable %d", tgt->tgt_name, enable); - if (enable && (tgt->rel_tgt_id == 0)) { - res = gen_relative_target_port_id(&tgt->rel_tgt_id); - if (res != 0) - goto out_put; - PRINT_INFO("Using autogenerated rel ID %d for target " - "%s", tgt->rel_tgt_id, tgt->tgt_name); - } else { - if (!scst_is_relative_target_port_id_unique( - tgt->rel_tgt_id, tgt)) { - PRINT_ERROR("Relative port id %d is not unique", - tgt->rel_tgt_id); - res = -EBADSLT; - goto out_put; + if (enable) { + if (tgt->rel_tgt_id == 0) { + res = gen_relative_target_port_id(&tgt->rel_tgt_id); + if (res != 0) + goto out_put; + PRINT_INFO("Using autogenerated rel ID %d for target " + "%s", tgt->rel_tgt_id, tgt->tgt_name); + } else { + if (!scst_is_relative_target_port_id_unique( + tgt->rel_tgt_id, tgt)) { + PRINT_ERROR("Relative port id %d is not unique", + tgt->rel_tgt_id); + res = -EBADSLT; + goto out_put; + } } }