Skip to content

Commit ebe7364

Browse files
Don Bracemartinkpetersen
authored andcommitted
scsi: cciss: correct check map error.
Remove device driver failed to check map error messages Reported-by: Johnny Bieren <[email protected]> Tested-by: Johnny Bieren <[email protected]> Reviewed-by: Scott Teel <[email protected]> Signed-off-by: Don Brace <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 669a311 commit ebe7364

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

drivers/block/cciss.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static void cciss_unmap_sg_chain_block(ctlr_info_t *h, CommandList_struct *c)
348348
pci_unmap_single(h->pdev, temp64.val, chain_sg->Len, PCI_DMA_TODEVICE);
349349
}
350350

351-
static void cciss_map_sg_chain_block(ctlr_info_t *h, CommandList_struct *c,
351+
static int cciss_map_sg_chain_block(ctlr_info_t *h, CommandList_struct *c,
352352
SGDescriptor_struct *chain_block, int len)
353353
{
354354
SGDescriptor_struct *chain_sg;
@@ -359,8 +359,16 @@ static void cciss_map_sg_chain_block(ctlr_info_t *h, CommandList_struct *c,
359359
chain_sg->Len = len;
360360
temp64.val = pci_map_single(h->pdev, chain_block, len,
361361
PCI_DMA_TODEVICE);
362+
if (dma_mapping_error(&h->pdev->dev, temp64.val)) {
363+
dev_warn(&h->pdev->dev,
364+
"%s: error mapping chain block for DMA\n",
365+
__func__);
366+
return -1;
367+
}
362368
chain_sg->Addr.lower = temp64.val32.lower;
363369
chain_sg->Addr.upper = temp64.val32.upper;
370+
371+
return 0;
364372
}
365373

366374
#include "cciss_scsi.c" /* For SCSI tape support */
@@ -3369,15 +3377,31 @@ static void do_cciss_request(struct request_queue *q)
33693377
temp64.val = (__u64) pci_map_page(h->pdev, sg_page(&tmp_sg[i]),
33703378
tmp_sg[i].offset,
33713379
tmp_sg[i].length, dir);
3380+
if (dma_mapping_error(&h->pdev->dev, temp64.val)) {
3381+
dev_warn(&h->pdev->dev,
3382+
"%s: error mapping page for DMA\n", __func__);
3383+
creq->errors = make_status_bytes(SAM_STAT_GOOD,
3384+
0, DRIVER_OK,
3385+
DID_SOFT_ERROR);
3386+
cmd_free(h, c);
3387+
return;
3388+
}
33723389
curr_sg[sg_index].Addr.lower = temp64.val32.lower;
33733390
curr_sg[sg_index].Addr.upper = temp64.val32.upper;
33743391
curr_sg[sg_index].Ext = 0; /* we are not chaining */
33753392
++sg_index;
33763393
}
3377-
if (chained)
3378-
cciss_map_sg_chain_block(h, c, h->cmd_sg_list[c->cmdindex],
3394+
if (chained) {
3395+
if (cciss_map_sg_chain_block(h, c, h->cmd_sg_list[c->cmdindex],
33793396
(seg - (h->max_cmd_sgentries - 1)) *
3380-
sizeof(SGDescriptor_struct));
3397+
sizeof(SGDescriptor_struct))) {
3398+
creq->errors = make_status_bytes(SAM_STAT_GOOD,
3399+
0, DRIVER_OK,
3400+
DID_SOFT_ERROR);
3401+
cmd_free(h, c);
3402+
return;
3403+
}
3404+
}
33813405

33823406
/* track how many SG entries we are using */
33833407
if (seg > h->maxSG)

0 commit comments

Comments
 (0)