public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] memslot check before deferencing
@ 2007-06-03 17:16 Nguyen Anh Quynh
       [not found] ` <9cde8bff0706031016r76fc236dga185be728f0e2f4e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Nguyen Anh Quynh @ 2007-06-03 17:16 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

[-- Attachment #1: Type: text/plain, Size: 169 bytes --]

"memslot" in makr_page_dirty() should be verified before dereferencing
it (kvm_main.c)

Signed-off-by: Nguyen Anh Quynh <aquynh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

[-- Attachment #2: patch9.patch --]
[-- Type: application/octet-stream, Size: 686 bytes --]

diff --git a/kernel/kvm_main.c b/kernel/kvm_main.c
index 84f95e4..da596fb 100644
--- a/kernel/kvm_main.c
+++ b/kernel/kvm_main.c
@@ -969,16 +969,16 @@ EXPORT_SYMBOL_GPL(gfn_to_page);
 void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
 {
 	int i;
-	struct kvm_memory_slot *memslot = NULL;
+	struct kvm_memory_slot *memslot;
 	unsigned long rel_gfn;
 
 	for (i = 0; i < kvm->nmemslots; ++i) {
 		memslot = &kvm->memslots[i];
 
-		if (gfn >= memslot->base_gfn
+		if (memslot && gfn >= memslot->base_gfn
 		    && gfn < memslot->base_gfn + memslot->npages) {
 
-			if (!memslot || !memslot->dirty_bitmap)
+			if (!memslot->dirty_bitmap)
 				return;
 
 			rel_gfn = gfn - memslot->base_gfn;

[-- Attachment #3: Type: text/plain, Size: 286 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-06-05  7:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-03 17:16 [PATCH] memslot check before deferencing Nguyen Anh Quynh
     [not found] ` <9cde8bff0706031016r76fc236dga185be728f0e2f4e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-06-04  9:45   ` Avi Kivity
     [not found]     ` <4663DF35.4080005-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-05  2:36       ` Nguyen Anh Quynh
     [not found]         ` <9cde8bff0706041936q1b29d7a5tc31bc1c6990e6df5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-06-05  7:35           ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox