diff --git a/lib/iscsi/tgt_node.c b/lib/iscsi/tgt_node.c index 00054dbee3..73960d162d 100644 --- a/lib/iscsi/tgt_node.c +++ b/lib/iscsi/tgt_node.c @@ -1283,8 +1283,8 @@ iscsi_tgt_node_add_lun(struct spdk_iscsi_tgt_node *target, return -1; } - if (lun_id < -1 || lun_id >= SPDK_SCSI_DEV_MAX_LUN) { - SPDK_ERRLOG("Specified LUN ID (%d) is invalid\n", lun_id); + if (lun_id < -1) { + SPDK_ERRLOG("Specified LUN ID (%d) is negative\n", lun_id); return -1; } diff --git a/lib/scsi/dev.c b/lib/scsi/dev.c index cc42481881..928accb082 100644 --- a/lib/scsi/dev.c +++ b/lib/scsi/dev.c @@ -153,6 +153,11 @@ spdk_scsi_dev_add_lun_ext(struct spdk_scsi_dev *dev, const char *bdev_name, int { struct spdk_scsi_lun *lun; + if (lun_id >= SPDK_SCSI_DEV_MAX_LUN) { + SPDK_ERRLOG("LUN ID %d is more than the maximum.\n", lun_id); + return -1; + } + /* Search the lowest free LUN ID if LUN ID is default */ if (lun_id == -1) { lun_id = scsi_dev_find_lowest_free_lun_id(dev);