Skip to content

Commit 56495f2

Browse files
cp890582martinkpetersen
authored andcommitted
scsi: megaraid_sas: Target with invalid LUN ID is deleted during scan
The megaraid_sas driver supports single LUN for RAID devices. That is LUN 0. All other LUNs are unsupported. When a device scan on a logical target with invalid LUN number is invoked through sysfs, that target ends up getting removed. Add LUN ID validation in the slave destroy function to avoid the target deletion. Link: https://lore.kernel.org/r/20220324094711.48833-1-chandrakanth.patil@broadcom.com Signed-off-by: Chandrakanth patil <chandrakanth.patil@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent bfb7789 commit 56495f2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

drivers/scsi/megaraid/megaraid_sas.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,6 +2560,9 @@ struct megasas_instance_template {
25602560
#define MEGASAS_IS_LOGICAL(sdev) \
25612561
((sdev->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1)
25622562

2563+
#define MEGASAS_IS_LUN_VALID(sdev) \
2564+
(((sdev)->lun == 0) ? 1 : 0)
2565+
25632566
#define MEGASAS_DEV_INDEX(scp) \
25642567
(((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \
25652568
scp->device->id)

drivers/scsi/megaraid/megaraid_sas_base.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,9 @@ static int megasas_slave_alloc(struct scsi_device *sdev)
21262126
goto scan_target;
21272127
}
21282128
return -ENXIO;
2129+
} else if (!MEGASAS_IS_LUN_VALID(sdev)) {
2130+
sdev_printk(KERN_INFO, sdev, "%s: invalid LUN\n", __func__);
2131+
return -ENXIO;
21292132
}
21302133

21312134
scan_target:
@@ -2156,6 +2159,10 @@ static void megasas_slave_destroy(struct scsi_device *sdev)
21562159
instance = megasas_lookup_instance(sdev->host->host_no);
21572160

21582161
if (MEGASAS_IS_LOGICAL(sdev)) {
2162+
if (!MEGASAS_IS_LUN_VALID(sdev)) {
2163+
sdev_printk(KERN_INFO, sdev, "%s: invalid LUN\n", __func__);
2164+
return;
2165+
}
21592166
ld_tgt_id = MEGASAS_TARGET_ID(sdev);
21602167
instance->ld_tgtid_status[ld_tgt_id] = LD_TARGET_ID_DELETED;
21612168
if (megasas_dbg_lvl & LD_PD_DEBUG)

0 commit comments

Comments
 (0)