Re: kernel NULL pointer dereference in blk_rq_map_sg with v2.6.23-6815-g0895e91

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jens Axboe
Date: Tuesday, October 23, 2007 - 5:47 am

On Tue, Oct 23 2007, Florin Iucha wrote:

This should fix it, sorry about that.

diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 61c2e39..de5ba47 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -1351,11 +1351,21 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
 new_segment:
 			if (!sg)
 				sg = sglist;
-			else
+			else {
+				/*
+				 * If the driver previously mapped a shorter
+				 * list, we could see a termination bit
+				 * prematurely unless it fully inits the sg
+				 * table on each mapping. We KNOW that there
+				 * must be more entries here or the driver
+				 * would be buggy, so force clear the
+				 * termination bit to avoid doing a full
+				 * sg_init_table() in drivers for each command.
+				 */
+				sg->page_link &= ~0x02;
 				sg = sg_next(sg);
+			}
 
-			sg_dma_len(sg) = 0;
-			sg_dma_address(sg) = 0;
 			sg_set_page(sg, bvec->bv_page);
 			sg->length = nbytes;
 			sg->offset = bvec->bv_offset;


-- 
Jens Axboe

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: kernel NULL pointer dereference in blk_rq_map_sg with ..., Jens Axboe, (Tue Oct 23, 5:47 am)