Skip to content

Commit bcc48ff

Browse files
Stephen M. CameronJames Bottomley
authored andcommitted
[SCSI] hpsa: check for dma_mapping_error in hpsa_passthru ioctls
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent c1f63c8 commit bcc48ff

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎drivers/scsi/hpsa.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,6 +3014,13 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp)
30143014
if (iocommand.buf_size > 0) {
30153015
temp64.val = pci_map_single(h->pdev, buff,
30163016
iocommand.buf_size, PCI_DMA_BIDIRECTIONAL);
3017+
if (dma_mapping_error(&h->pdev->dev, temp64.val)) {
3018+
c->SG[0].Addr.lower = 0;
3019+
c->SG[0].Addr.upper = 0;
3020+
c->SG[0].Len = 0;
3021+
rc = -ENOMEM;
3022+
goto out;
3023+
}
30173024
c->SG[0].Addr.lower = temp64.val32.lower;
30183025
c->SG[0].Addr.upper = temp64.val32.upper;
30193026
c->SG[0].Len = iocommand.buf_size;
@@ -3135,6 +3142,15 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
31353142
for (i = 0; i < sg_used; i++) {
31363143
temp64.val = pci_map_single(h->pdev, buff[i],
31373144
buff_size[i], PCI_DMA_BIDIRECTIONAL);
3145+
if (dma_mapping_error(&h->pdev->dev, temp64.val)) {
3146+
c->SG[i].Addr.lower = 0;
3147+
c->SG[i].Addr.upper = 0;
3148+
c->SG[i].Len = 0;
3149+
hpsa_pci_unmap(h->pdev, c, i,
3150+
PCI_DMA_BIDIRECTIONAL);
3151+
status = -ENOMEM;
3152+
goto cleanup1;
3153+
}
31383154
c->SG[i].Addr.lower = temp64.val32.lower;
31393155
c->SG[i].Addr.upper = temp64.val32.upper;
31403156
c->SG[i].Len = buff_size[i];

0 commit comments

Comments
 (0)