@@ -348,7 +348,7 @@ static void cciss_unmap_sg_chain_block(ctlr_info_t *h, CommandList_struct *c)
348
348
pci_unmap_single (h -> pdev , temp64 .val , chain_sg -> Len , PCI_DMA_TODEVICE );
349
349
}
350
350
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 ,
352
352
SGDescriptor_struct * chain_block , int len )
353
353
{
354
354
SGDescriptor_struct * chain_sg ;
@@ -359,8 +359,16 @@ static void cciss_map_sg_chain_block(ctlr_info_t *h, CommandList_struct *c,
359
359
chain_sg -> Len = len ;
360
360
temp64 .val = pci_map_single (h -> pdev , chain_block , len ,
361
361
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
+ }
362
368
chain_sg -> Addr .lower = temp64 .val32 .lower ;
363
369
chain_sg -> Addr .upper = temp64 .val32 .upper ;
370
+
371
+ return 0 ;
364
372
}
365
373
366
374
#include "cciss_scsi.c" /* For SCSI tape support */
@@ -3369,15 +3377,31 @@ static void do_cciss_request(struct request_queue *q)
3369
3377
temp64 .val = (__u64 ) pci_map_page (h -> pdev , sg_page (& tmp_sg [i ]),
3370
3378
tmp_sg [i ].offset ,
3371
3379
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
+ }
3372
3389
curr_sg [sg_index ].Addr .lower = temp64 .val32 .lower ;
3373
3390
curr_sg [sg_index ].Addr .upper = temp64 .val32 .upper ;
3374
3391
curr_sg [sg_index ].Ext = 0 ; /* we are not chaining */
3375
3392
++ sg_index ;
3376
3393
}
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 ],
3379
3396
(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
+ }
3381
3405
3382
3406
/* track how many SG entries we are using */
3383
3407
if (seg > h -> maxSG )
0 commit comments