aio: fix possible invalid memory access when DEBUG is enabled [Linux 3.9]

This Linux kernel change "aio: fix possible invalid memory access when DEBUG is enabled" is included in the Linux 3.9 release. This change is authored by Zhao Hongjiang <zhaohongjiang [at] huawei.com> on Fri Apr 26 11:03:53 2013 +0800. The commit for this change in Linux stable tree is 91d80a8 (patch).

aio: fix possible invalid memory access when DEBUG is enabled

dprintk() shouldn't access @ring after it's unmapped.

Signed-off-by: Zhao Hongjiang <[email protected]>
Cc: [email protected]
Signed-off-by: Linus Torvalds <[email protected]>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 fs/aio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/aio.c b/fs/aio.c
index 3f941f2..1dc8786 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1029,9 +1029,9 @@ static int aio_read_evt(struct kioctx *ioctx, struct io_event *ent)
    spin_unlock(&info->ring_lock);

 out:
-   kunmap_atomic(ring);
    dprintk("leaving aio_read_evt: %d  h%lu t%lun", ret,
         (unsigned long)ring->head, (unsigned long)ring->tail);
+   kunmap_atomic(ring);
    return ret;
 }

Leave a Reply

Your email address will not be published. Required fields are marked *