Skip to content

Commit

Permalink
kexec: prevent double free on image allocation failure
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Zhang Yanfei <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
sashalevin authored and torvalds committed Feb 28, 2013
1 parent 0d0bf66 commit fe88f2e
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions kernel/kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fe88f2e

Please sign in to comment.