Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0a6d3a2a3813e7b25267366cfbf9a4a4698dd1c2
Commit:     0a6d3a2a3813e7b25267366cfbf9a4a4698dd1c2
Parent:     7ff9057db7edeb210fd5c00314c52154922d8868
Author:     Jeff Dike <[EMAIL PROTECTED]>
AuthorDate: Sun Jul 15 23:38:47 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Mon Jul 16 09:05:38 2007 -0700

    uml: fix request->sector update
    
    It is theoretically possible for a request to finish and be freed between
    writing it to the I/O thread and updating the sector count.  In this case, 
the
    update will dereference a freed pointer.
    
    To avoid this, I delay the update until processing the next sg segment, when
    the request pointer is known to be good.
    
    Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 arch/um/drivers/ubd_kern.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 2e09f16..0947f2e 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1083,7 +1083,7 @@ static void do_ubd_request(request_queue_t *q)
 {
        struct io_thread_req *io_req;
        struct request *req;
-       int n;
+       int n, last_sectors;
 
        while(1){
                struct ubd *dev = q->queuedata;
@@ -1099,9 +1099,11 @@ static void do_ubd_request(request_queue_t *q)
                }
 
                req = dev->request;
+               last_sectors = 0;
                while(dev->start_sg < dev->end_sg){
                        struct scatterlist *sg = &dev->sg[dev->start_sg];
 
+                       req->sector += last_sectors;
                        io_req = kmalloc(sizeof(struct io_thread_req),
                                         GFP_ATOMIC);
                        if(io_req == NULL){
@@ -1113,6 +1115,7 @@ static void do_ubd_request(request_queue_t *q)
                                        (unsigned long long) req->sector << 9,
                                        sg->offset, sg->length, sg->page);
 
+                       last_sectors = sg->length >> 9;
                        n = os_write_file(thread_fd, &io_req,
                                          sizeof(struct io_thread_req *));
                        if(n != sizeof(struct io_thread_req *)){
@@ -1124,7 +1127,6 @@ static void do_ubd_request(request_queue_t *q)
                                return;
                        }
 
-                       req->sector += sg->length >> 9;
                        dev->start_sg++;
                }
                dev->end_sg = 0;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to