diff options
-rw-r--r-- | drivers/scsi/scsi_lib.c | 9 | ||||
-rw-r--r-- | drivers/scsi/scsi_tgt_lib.c | 4 | ||||
-rw-r--r-- | include/scsi/scsi_cmnd.h | 2 |
3 files changed, 8 insertions, 7 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 960f949b8f8f..7e1dcc57f115 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -741,13 +741,14 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) | |||
741 | 741 | ||
742 | EXPORT_SYMBOL(scsi_alloc_sgtable); | 742 | EXPORT_SYMBOL(scsi_alloc_sgtable); |
743 | 743 | ||
744 | void scsi_free_sgtable(struct scatterlist *sgl, int index) | 744 | void scsi_free_sgtable(struct scsi_cmnd *cmd) |
745 | { | 745 | { |
746 | struct scatterlist *sgl = cmd->request_buffer; | ||
746 | struct scsi_host_sg_pool *sgp; | 747 | struct scsi_host_sg_pool *sgp; |
747 | 748 | ||
748 | BUG_ON(index >= SG_MEMPOOL_NR); | 749 | BUG_ON(cmd->sglist_len >= SG_MEMPOOL_NR); |
749 | 750 | ||
750 | sgp = scsi_sg_pools + index; | 751 | sgp = scsi_sg_pools + cmd->sglist_len; |
751 | mempool_free(sgl, sgp->pool); | 752 | mempool_free(sgl, sgp->pool); |
752 | } | 753 | } |
753 | 754 | ||
@@ -773,7 +774,7 @@ EXPORT_SYMBOL(scsi_free_sgtable); | |||
773 | static void scsi_release_buffers(struct scsi_cmnd *cmd) | 774 | static void scsi_release_buffers(struct scsi_cmnd *cmd) |
774 | { | 775 | { |
775 | if (cmd->use_sg) | 776 | if (cmd->use_sg) |
776 | scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); | 777 | scsi_free_sgtable(cmd); |
777 | 778 | ||
778 | /* | 779 | /* |
779 | * Zero these out. They now point to freed memory, and it is | 780 | * Zero these out. They now point to freed memory, and it is |
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c index 66c692ffa305..a91761c3645f 100644 --- a/drivers/scsi/scsi_tgt_lib.c +++ b/drivers/scsi/scsi_tgt_lib.c | |||
@@ -332,7 +332,7 @@ static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd) | |||
332 | scsi_tgt_uspace_send_status(cmd, tcmd->itn_id, tcmd->tag); | 332 | scsi_tgt_uspace_send_status(cmd, tcmd->itn_id, tcmd->tag); |
333 | 333 | ||
334 | if (cmd->request_buffer) | 334 | if (cmd->request_buffer) |
335 | scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); | 335 | scsi_free_sgtable(cmd); |
336 | 336 | ||
337 | queue_work(scsi_tgtd, &tcmd->work); | 337 | queue_work(scsi_tgtd, &tcmd->work); |
338 | } | 338 | } |
@@ -373,7 +373,7 @@ static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask) | |||
373 | } | 373 | } |
374 | 374 | ||
375 | eprintk("cmd %p cnt %d\n", cmd, cmd->use_sg); | 375 | eprintk("cmd %p cnt %d\n", cmd, cmd->use_sg); |
376 | scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); | 376 | scsi_free_sgtable(cmd); |
377 | return -EINVAL; | 377 | return -EINVAL; |
378 | } | 378 | } |
379 | 379 | ||
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 3b0bb6680e62..a5439a4b8f97 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h | |||
@@ -129,7 +129,7 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, | |||
129 | extern void scsi_kunmap_atomic_sg(void *virt); | 129 | extern void scsi_kunmap_atomic_sg(void *virt); |
130 | 130 | ||
131 | extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t); | 131 | extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t); |
132 | extern void scsi_free_sgtable(struct scatterlist *, int); | 132 | extern void scsi_free_sgtable(struct scsi_cmnd *); |
133 | 133 | ||
134 | extern int scsi_dma_map(struct scsi_cmnd *cmd); | 134 | extern int scsi_dma_map(struct scsi_cmnd *cmd); |
135 | extern void scsi_dma_unmap(struct scsi_cmnd *cmd); | 135 | extern void scsi_dma_unmap(struct scsi_cmnd *cmd); |