Skip to content

Commit 9ecd656

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: fix fcport null pointer access.
This patch allocates DMA memory to prevent NULL pointer access for ct_sns request while sending switch commands. Signed-off-by: Quinn Tran <[email protected]> Signed-off-by: Himanshu Madhani <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 51fd6e6 commit 9ecd656

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/scsi/qla2xxx/qla_init.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4755,6 +4755,16 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
47554755
if (!fcport)
47564756
return NULL;
47574757

4758+
fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev,
4759+
sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma,
4760+
flags);
4761+
if (!fcport->ct_desc.ct_sns) {
4762+
ql_log(ql_log_warn, vha, 0xd049,
4763+
"Failed to allocate ct_sns request.\n");
4764+
kfree(fcport);
4765+
return NULL;
4766+
}
4767+
47584768
/* Setup fcport template structure. */
47594769
fcport->vha = vha;
47604770
fcport->port_type = FCT_UNKNOWN;
@@ -4763,13 +4773,11 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
47634773
fcport->supported_classes = FC_COS_UNSPECIFIED;
47644774
fcport->fp_speed = PORT_SPEED_UNKNOWN;
47654775

4766-
fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev,
4767-
sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma,
4768-
flags);
47694776
fcport->disc_state = DSC_DELETED;
47704777
fcport->fw_login_state = DSC_LS_PORT_UNAVAIL;
47714778
fcport->deleted = QLA_SESS_DELETED;
47724779
fcport->login_retry = vha->hw->login_retry_count;
4780+
fcport->chip_reset = vha->hw->base_qpair->chip_reset;
47734781
fcport->logout_on_delete = 1;
47744782

47754783
if (!fcport->ct_desc.ct_sns) {
@@ -4778,6 +4786,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
47784786
kfree(fcport);
47794787
fcport = NULL;
47804788
}
4789+
47814790
INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn);
47824791
INIT_WORK(&fcport->reg_work, qla_register_fcport_fn);
47834792
INIT_LIST_HEAD(&fcport->gnl_entry);

0 commit comments

Comments
 (0)