kexec: copy only happens before uchunk goes to zero
authoryang.zhang <yang.zhang@hexintek.com>
Thu, 22 Feb 2024 09:21:19 +0000 (17:21 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 6 Mar 2024 21:07:39 +0000 (13:07 -0800)
commit4bb7be96fc8871f37ff705e02443a0526fb4df8d
tree1fd46e7a27fe921d4004d58a464779399b06a291
parenta436184e3bfb14b3c38e6ed0c2e7f6d810312c4f
kexec: copy only happens before uchunk goes to zero

When loading segments, ubytes is <= mbytes.  When ubytes is exhausted,
there could be remaining mbytes.  Then in the while loop, the buf pointer
advancing with mchunk will causing meaningless reading even though it
doesn't harm.

So let's change to make sure that all of the copying and the rest only
happens before uchunk goes to zero.

Link: https://lkml.kernel.org/r/20240222092119.5602-1-gaoshanliukou@163.com
Signed-off-by: yang.zhang <yang.zhang@hexintek.com>
Acked-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/kexec_core.c