Skip to content

Commit

Permalink
kexec: return error number directly
Browse files Browse the repository at this point in the history
This is a cleanup patch to make kexec more clear to return error number
directly.  The variable result is useless, because there is no other
function's return value assignes to it.  So remove it.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Minfei Huang <[email protected]>
Cc: Dave Young <[email protected]>
Cc: Baoquan He <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Xunlei Pang <[email protected]>
Cc: Atsushi Kumagai <[email protected]>
Cc: Vivek Goyal <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Minfei Huang authored and torvalds committed Aug 2, 2016
1 parent b06fb41 commit 4caf961
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions kernel/kexec_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static struct page *kimage_alloc_page(struct kimage *image,

int sanity_check_segment_list(struct kimage *image)
{
int result, i;
int i;
unsigned long nr_segments = image->nr_segments;

/*
Expand All @@ -163,24 +163,22 @@ int sanity_check_segment_list(struct kimage *image)
* simply because addresses are changed to page size
* granularity.
*/
result = -EADDRNOTAVAIL;
for (i = 0; i < nr_segments; i++) {
unsigned long mstart, mend;

mstart = image->segment[i].mem;
mend = mstart + image->segment[i].memsz;
if ((mstart & ~PAGE_MASK) || (mend & ~PAGE_MASK))
return result;
return -EADDRNOTAVAIL;
if (mend >= KEXEC_DESTINATION_MEMORY_LIMIT)
return result;
return -EADDRNOTAVAIL;
}

/* Verify our destination addresses do not overlap.
* If we alloed overlapping destination addresses
* through very weird things can happen with no
* easy explanation as one segment stops on another.
*/
result = -EINVAL;
for (i = 0; i < nr_segments; i++) {
unsigned long mstart, mend;
unsigned long j;
Expand All @@ -194,7 +192,7 @@ int sanity_check_segment_list(struct kimage *image)
pend = pstart + image->segment[j].memsz;
/* Do the segments overlap ? */
if ((mend > pstart) && (mstart < pend))
return result;
return -EINVAL;
}
}

Expand All @@ -203,10 +201,9 @@ int sanity_check_segment_list(struct kimage *image)
* and it is easier to check up front than to be surprised
* later on.
*/
result = -EINVAL;
for (i = 0; i < nr_segments; i++) {
if (image->segment[i].bufsz > image->segment[i].memsz)
return result;
return -EINVAL;
}

/*
Expand All @@ -220,7 +217,6 @@ int sanity_check_segment_list(struct kimage *image)
*/

if (image->type == KEXEC_TYPE_CRASH) {
result = -EADDRNOTAVAIL;
for (i = 0; i < nr_segments; i++) {
unsigned long mstart, mend;

Expand All @@ -229,7 +225,7 @@ int sanity_check_segment_list(struct kimage *image)
/* Ensure we are within the crash kernel limits */
if ((mstart < crashk_res.start) ||
(mend > crashk_res.end))
return result;
return -EADDRNOTAVAIL;
}
}

Expand Down

0 comments on commit 4caf961

Please sign in to comment.