Skip to content

Commit

Permalink
snic: Fix use-after-free in case of a dma mapping error
Browse files Browse the repository at this point in the history
If there is a dma mapping error snic kfree()s buf right before printing
it.  Change the order to not accidently trip on memory that's not owned
by us anymore.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Narsimhulu Musini <nmusini@cisco.com>
Reviewed-by: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Johannes Thumshirn authored and Martin K. Petersen committed Jul 13, 2016
1 parent 40e4c0a commit 2a6a20e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/scsi/snic/snic_disc.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ snic_queue_report_tgt_req(struct snic *snic)

pa = pci_map_single(snic->pdev, buf, buf_len, PCI_DMA_FROMDEVICE);
if (pci_dma_mapping_error(snic->pdev, pa)) {
kfree(buf);
snic_req_free(snic, rqi);
SNIC_HOST_ERR(snic->shost,
"Rpt-tgt rspbuf %p: PCI DMA Mapping Failed\n",
buf);
kfree(buf);
snic_req_free(snic, rqi);
ret = -EINVAL;

goto error;
Expand Down

0 comments on commit 2a6a20e

Please sign in to comment.