From: Omar Sandoval <osan...@fb.com>

If floppy_end_request() gets passed an error, it should end the whole
request, not just the current segment.

Signed-off-by: Omar Sandoval <osan...@fb.com>
---
 drivers/block/floppy.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index f2b6f4da1034..acbafd831ea3 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -2210,13 +2210,15 @@ static int do_format(int drive, struct format_descr 
*tmp_format_req)
 
 static void floppy_end_request(struct request *req, blk_status_t error)
 {
-       unsigned int nr_sectors = current_count_sectors;
+       unsigned int nr_bytes;
        unsigned int drive = (unsigned long)req->rq_disk->private_data;
 
        /* current_count_sectors can be zero if transfer failed */
        if (error)
-               nr_sectors = blk_rq_cur_sectors(req);
-       if (__blk_end_request(req, error, nr_sectors << 9))
+               nr_bytes = blk_rq_bytes(req);
+       else
+               nr_bytes = current_count_sectors << 9;
+       if (__blk_end_request(req, error, nr_bytes))
                return;
 
        /* We're done with the request */
-- 
2.19.1

Reply via email to