Skip to content

Commit f81426a

Browse files
dangJames Bottomley
authored andcommitted
[SCSI] fix for bidi use after free
When ending a bi-directionional SCSI request, blk_finish_request() cleans up and frees the request, but scsi_release_bidi_buffers() tries to indirect through the request to find it's data buffers. This causes a panic due to a null pointer dereference. Move the call to scsi_release_bidi_buffers() before the call to blk_finish_request(). Signed-off-by: Daniel Gryniewicz <[email protected]> Reviewed-by: Webb Scales <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent e8be1cf commit f81426a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,12 +733,13 @@ static bool scsi_end_request(struct request *req, int error,
733733
} else {
734734
unsigned long flags;
735735

736+
if (bidi_bytes)
737+
scsi_release_bidi_buffers(cmd);
738+
736739
spin_lock_irqsave(q->queue_lock, flags);
737740
blk_finish_request(req, error);
738741
spin_unlock_irqrestore(q->queue_lock, flags);
739742

740-
if (bidi_bytes)
741-
scsi_release_bidi_buffers(cmd);
742743
scsi_release_buffers(cmd);
743744
scsi_next_command(cmd);
744745
}

0 commit comments

Comments
 (0)