kvm: load_bzimage: Proper check for number of setup sectors

We should check for the number of setup sectors before adding the last one.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
This commit is contained in:
Cyrill Gorcunov
2015-06-01 16:39:38 +01:00
committed by Will Deacon
parent 6753ed2f8c
commit 4cf542bbd7
+2 -2
View File
@@ -218,9 +218,9 @@ static bool load_bzimage(struct kvm *self, int fd)
if (lseek(fd, 0, SEEK_SET) < 0)
die_perror("lseek");
if (!boot.hdr.setup_sects)
boot.hdr.setup_sects = BZ_DEFAULT_SETUP_SECTS;
setup_sects = boot.hdr.setup_sects + 1;
if (setup_sects == 0)
setup_sects = BZ_DEFAULT_SETUP_SECTS;
setup_size = setup_sects << 9;
p = guest_real_to_host(self, BOOT_LOADER_SELECTOR, BOOT_LOADER_IP);