diff options
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r-- | drivers/scsi/scsi_lib.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 1a7e8d811a08..aac8a02cbe80 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -769,10 +769,8 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) | |||
769 | /* | 769 | /* |
770 | * first loop through, set initial index and return value | 770 | * first loop through, set initial index and return value |
771 | */ | 771 | */ |
772 | if (!ret) { | 772 | if (!ret) |
773 | cmd->sglist_len = index; | ||
774 | ret = sgl; | 773 | ret = sgl; |
775 | } | ||
776 | 774 | ||
777 | /* | 775 | /* |
778 | * chain previous sglist, if any. we know the previous | 776 | * chain previous sglist, if any. we know the previous |
@@ -825,8 +823,6 @@ void scsi_free_sgtable(struct scsi_cmnd *cmd) | |||
825 | struct scatterlist *sgl = cmd->request_buffer; | 823 | struct scatterlist *sgl = cmd->request_buffer; |
826 | struct scsi_host_sg_pool *sgp; | 824 | struct scsi_host_sg_pool *sgp; |
827 | 825 | ||
828 | BUG_ON(cmd->sglist_len >= SG_MEMPOOL_NR); | ||
829 | |||
830 | /* | 826 | /* |
831 | * if this is the biggest size sglist, check if we have | 827 | * if this is the biggest size sglist, check if we have |
832 | * chained parts we need to free | 828 | * chained parts we need to free |
@@ -861,9 +857,10 @@ void scsi_free_sgtable(struct scsi_cmnd *cmd) | |||
861 | * Restore original, will be freed below | 857 | * Restore original, will be freed below |
862 | */ | 858 | */ |
863 | sgl = cmd->request_buffer; | 859 | sgl = cmd->request_buffer; |
864 | } | 860 | sgp = scsi_sg_pools + SG_MEMPOOL_NR - 1; |
861 | } else | ||
862 | sgp = scsi_sg_pools + scsi_sgtable_index(cmd->__use_sg); | ||
865 | 863 | ||
866 | sgp = scsi_sg_pools + cmd->sglist_len; | ||
867 | mempool_free(sgl, sgp->pool); | 864 | mempool_free(sgl, sgp->pool); |
868 | } | 865 | } |
869 | 866 | ||