kexec: prevent double free on image allocation failure
authorSasha Levin <sasha.levin@oracle.com>
Thu, 28 Feb 2013 01:03:28 +0000 (17:03 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Feb 2013 03:10:12 +0000 (19:10 -0800)
If kimage_normal_alloc() fails to initialize an allocated kimage, it will
free the image but would still set 'rimage', as a result kexec_load will
try to free it again.

This would explode as part of the freeing process is accessing internal
members which point to uninitialized memory.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/kexec.c

index 2348bd6ef2af52aed12c7f04171b61c4f19c1950..855bfbbf4048699b827601c3f9e122a1f8df738c 100644 (file)
@@ -242,8 +242,6 @@ static int kimage_normal_alloc(struct kimage **rimage, unsigned long entry,
        if (result)
                goto out;
 
-       *rimage = image;
-
        /*
         * Find a location for the control code buffer, and add it
         * the vector of segments so that it's pages will also be