Commit 22070634 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by James Bottomley

advansys: Check for DMA mapping errors

DMA mapping might fail, so we need to check for errors here.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarJames Bottomley <JBottomley@Odin.com>
parent e14f66e9
...@@ -7514,6 +7514,10 @@ static __le32 advansys_get_sense_buffer_dma(struct scsi_cmnd *scp) ...@@ -7514,6 +7514,10 @@ static __le32 advansys_get_sense_buffer_dma(struct scsi_cmnd *scp)
struct asc_board *board = shost_priv(scp->device->host); struct asc_board *board = shost_priv(scp->device->host);
scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer, scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer,
SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
if (dma_mapping_error(board->dev, scp->SCp.dma_handle)) {
ASC_DBG(1, "failed to map sense buffer\n");
return 0;
}
dma_cache_sync(board->dev, scp->sense_buffer, dma_cache_sync(board->dev, scp->sense_buffer,
SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
return cpu_to_le32(scp->SCp.dma_handle); return cpu_to_le32(scp->SCp.dma_handle);
...@@ -7546,6 +7550,8 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, ...@@ -7546,6 +7550,8 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun); ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp); asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);
asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE; asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE;
if (!asc_scsi_q->q1.sense_addr)
return ASC_BUSY;
/* /*
* If there are any outstanding requests for the current target, * If there are any outstanding requests for the current target,
...@@ -7567,7 +7573,10 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, ...@@ -7567,7 +7573,10 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
/* Build ASC_SCSI_Q */ /* Build ASC_SCSI_Q */
use_sg = scsi_dma_map(scp); use_sg = scsi_dma_map(scp);
if (use_sg != 0) { if (use_sg < 0) {
ASC_DBG(1, "failed to map sglist\n");
return ASC_BUSY;
} else if (use_sg > 0) {
int sgcnt; int sgcnt;
struct scatterlist *slp; struct scatterlist *slp;
struct asc_sg_head *asc_sg_head; struct asc_sg_head *asc_sg_head;
...@@ -7799,13 +7808,22 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, ...@@ -7799,13 +7808,22 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
sense_addr = dma_map_single(boardp->dev, scp->sense_buffer, sense_addr = dma_map_single(boardp->dev, scp->sense_buffer,
SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
if (dma_mapping_error(boardp->dev, sense_addr)) {
ASC_DBG(1, "failed to map sense buffer\n");
ASC_STATS(scp->device->host, adv_build_noreq);
return ASC_BUSY;
}
scsiqp->sense_addr = cpu_to_le32(sense_addr); scsiqp->sense_addr = cpu_to_le32(sense_addr);
scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE); scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
/* Build ADV_SCSI_REQ_Q */ /* Build ADV_SCSI_REQ_Q */
use_sg = scsi_dma_map(scp); use_sg = scsi_dma_map(scp);
if (use_sg == 0) { if (use_sg < 0) {
ASC_DBG(1, "failed to map SG list\n");
ASC_STATS(scp->device->host, adv_build_noreq);
return ASC_BUSY;
} else if (use_sg == 0) {
/* Zero-length transfer */ /* Zero-length transfer */
reqp->sgblkp = NULL; reqp->sgblkp = NULL;
scsiqp->data_cnt = 0; scsiqp->data_cnt = 0;
...@@ -8473,11 +8491,10 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp) ...@@ -8473,11 +8491,10 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var; ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
struct asc_scsi_q asc_scsi_q; struct asc_scsi_q asc_scsi_q;
/* asc_build_req() can not return ASC_BUSY. */
ret = asc_build_req(boardp, scp, &asc_scsi_q); ret = asc_build_req(boardp, scp, &asc_scsi_q);
if (ret == ASC_ERROR) { if (ret != ASC_NOERROR) {
ASC_STATS(scp->device->host, build_error); ASC_STATS(scp->device->host, build_error);
return ASC_ERROR; return ret;
} }
ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q); ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment