Skip to content

Commit 58968fc

Browse files
hreineckeJames Bottomley
authored andcommitted
[SCSI] megaraid_sas: check return value for megasas_get_pd_list()
When megasas_get_pd_list() fails we cannot detect any drives, so we should be checking the return value accordingly. [jejb: checkpatch fix] Signed-off-by: Hannes Reinecke <hare@suse.de> Acked-by: Kashyap Desai <kashyap.desai@lsi.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent 2f8bdfa commit 58968fc

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

drivers/scsi/megaraid/megaraid_sas_base.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3763,7 +3763,10 @@ static int megasas_init_fw(struct megasas_instance *instance)
37633763

37643764
memset(instance->pd_list, 0 ,
37653765
(MEGASAS_MAX_PD * sizeof(struct megasas_pd_list)));
3766-
megasas_get_pd_list(instance);
3766+
if (megasas_get_pd_list(instance) < 0) {
3767+
printk(KERN_ERR "megasas: failed to get PD list\n");
3768+
goto fail_init_adapter;
3769+
}
37673770

37683771
memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
37693772
if (megasas_ld_list_query(instance,
@@ -5592,22 +5595,23 @@ megasas_aen_polling(struct work_struct *work)
55925595

55935596
if (doscan) {
55945597
printk(KERN_INFO "scanning ...\n");
5595-
megasas_get_pd_list(instance);
5596-
for (i = 0; i < MEGASAS_MAX_PD_CHANNELS; i++) {
5597-
for (j = 0; j < MEGASAS_MAX_DEV_PER_CHANNEL; j++) {
5598-
pd_index = i*MEGASAS_MAX_DEV_PER_CHANNEL + j;
5599-
sdev1 = scsi_device_lookup(host, i, j, 0);
5600-
if (instance->pd_list[pd_index].driveState ==
5601-
MR_PD_STATE_SYSTEM) {
5602-
if (!sdev1) {
5603-
scsi_add_device(host, i, j, 0);
5604-
}
5605-
if (sdev1)
5606-
scsi_device_put(sdev1);
5607-
} else {
5608-
if (sdev1) {
5609-
scsi_remove_device(sdev1);
5610-
scsi_device_put(sdev1);
5598+
if (megasas_get_pd_list(instance) == 0) {
5599+
for (i = 0; i < MEGASAS_MAX_PD_CHANNELS; i++) {
5600+
for (j = 0; j < MEGASAS_MAX_DEV_PER_CHANNEL; j++) {
5601+
pd_index = i*MEGASAS_MAX_DEV_PER_CHANNEL + j;
5602+
sdev1 = scsi_device_lookup(host, i, j, 0);
5603+
if (instance->pd_list[pd_index].driveState ==
5604+
MR_PD_STATE_SYSTEM) {
5605+
if (!sdev1) {
5606+
scsi_add_device(host, i, j, 0);
5607+
}
5608+
if (sdev1)
5609+
scsi_device_put(sdev1);
5610+
} else {
5611+
if (sdev1) {
5612+
scsi_remove_device(sdev1);
5613+
scsi_device_put(sdev1);
5614+
}
56115615
}
56125616
}
56135617
}

0 commit comments

Comments
 (0)