Skip to content

Commit f7f567b

Browse files
Zhen Leiakpm00
authored andcommitted
kexec: clear crashk_res if all its memory has been released
If the resource of crashk_res has been released, it is better to clear crashk_res.start and crashk_res.end. Because 'end = start - 1' is not reasonable, and in some places the test is based on crashk_res.end, not resource_size(&crashk_res). Link: https://lkml.kernel.org/r/20230527123439.772-4-thunder.leizhen@huawei.com Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Acked-by: Baoquan He <bhe@redhat.com> Cc: Cong Wang <amwang@redhat.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Michael Holzheu <holzheu@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 6f22a74 commit f7f567b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

kernel/kexec_core.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,15 +1137,18 @@ int crash_shrink_memory(unsigned long new_size)
11371137
end = start + new_size;
11381138
crash_free_reserved_phys_range(end, crashk_res.end);
11391139

1140-
if (start == end)
1141-
release_resource(&crashk_res);
1142-
11431140
ram_res->start = end;
11441141
ram_res->end = crashk_res.end;
11451142
ram_res->flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM;
11461143
ram_res->name = "System RAM";
11471144

1148-
crashk_res.end = end - 1;
1145+
if (start == end) {
1146+
release_resource(&crashk_res);
1147+
crashk_res.start = 0;
1148+
crashk_res.end = 0;
1149+
} else {
1150+
crashk_res.end = end - 1;
1151+
}
11491152

11501153
insert_resource(&iomem_resource, ram_res);
11511154

0 commit comments

Comments
 (0)