qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Check for invalid initrd file


From: M. Mohan Kumar
Subject: [Qemu-devel] [PATCH] Check for invalid initrd file
Date: Thu, 4 Mar 2010 14:32:24 +0530
User-agent: KMail/1.13.0 (Linux/2.6.31.12-174.2.22.fc12.x86_64; KDE/4.4.0; x86_64; ; )

From c5dca54f67ec6aac16c6c5e09958417b2b3ee5a1 Mon Sep 17 00:00:00 2001
From: M. Mohan Kumar <address@hidden>
Date: Thu, 4 Mar 2010 14:23:07 +0530
Subject: [PATCH] Check for invalid initrd file

When qemu is invoked with an invalid initrd file, it crashes. Following
patch prints a error message and exits if an invalid initrd is specified.

Signed-off-by: M. Mohan Kumar <address@hidden>
---
 hw/pc.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 4f6a522..551c901 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -669,6 +669,12 @@ static void load_linux(void *fw_cfg,
        }
 
        initrd_size = get_image_size(initrd_filename);
+       if (initrd_size < 0) {
+               fprintf(stderr, "qemu: initrd %s does not exist\n",
+                                                       initrd_filename);
+               exit(1);
+       }
+
         initrd_addr = (initrd_max-initrd_size) & ~4095;
 
         initrd_data = qemu_malloc(initrd_size);
-- 
1.6.6.1


-- 
M. Mohan Kumar,
Linux Technology Center, IBM India




reply via email to

[Prev in Thread] Current Thread [Next in Thread]