aio: nullify aio->ring_pages after freeing it

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Nov 22 17:59:04 EST 2013


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=ddb8c45ba15149ebd41d7586261c05f7ca37f9a1
Commit:     ddb8c45ba15149ebd41d7586261c05f7ca37f9a1
Parent:     d558023207e008a4476a3b7bb8706b2a2bf5d84f
Author:     Sasha Levin <sasha.levin at oracle.com>
AuthorDate: Tue Nov 19 17:33:03 2013 -0500
Committer:  Benjamin LaHaise <bcrl at kvack.org>
CommitDate: Tue Nov 19 17:40:48 2013 -0500

    aio: nullify aio->ring_pages after freeing it
    
    After freeing ring_pages we leave it as is causing a dangling pointer. This
    has already caused an issue so to help catching any issues in the future
    NULL it out.
    
    Signed-off-by: Sasha Levin <sasha.levin at oracle.com>
    Signed-off-by: Benjamin LaHaise <bcrl at kvack.org>
---
 fs/aio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/aio.c b/fs/aio.c
index 6313533..ad460d7 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -196,8 +196,10 @@ static void aio_free_ring(struct kioctx *ctx)
 
 	put_aio_ring_file(ctx);
 
-	if (ctx->ring_pages && ctx->ring_pages != ctx->internal_pages)
+	if (ctx->ring_pages && ctx->ring_pages != ctx->internal_pages) {
 		kfree(ctx->ring_pages);
+		ctx->ring_pages = NULL;
+	}
 }
 
 static int aio_ring_mmap(struct file *file, struct vm_area_struct *vma)



More information about the linux-mtd-cvs mailing list