From: "Jan Beulich" Subject: [PATCH] x86: fix error handling in MTRR code Date: Wed, 04 Oct 2006 17:15:29 +0200 Message-ID: <4523EC31.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Signed-off-by: Jan Beulich Index: 2006-09-21/xen/arch/x86/platform_hypercall.c =================================================================== --- 2006-09-21.orig/xen/arch/x86/platform_hypercall.c 2006-08-28 08:32:37.000000000 +0200 +++ 2006-09-21/xen/arch/x86/platform_hypercall.c 2006-09-27 17:14:22.000000000 +0200 @@ -58,12 +58,17 @@ long do_platform_op(XEN_GUEST_HANDLE(xen op->u.add_memtype.nr_mfns, op->u.add_memtype.type, 1); - if ( ret > 0 ) + if ( ret >= 0 ) { op->u.add_memtype.handle = 0; op->u.add_memtype.reg = ret; - (void)copy_to_guest(u_xenpf_op, op, 1); - ret = 0; + if ( copy_to_guest(u_xenpf_op, op, 1) == 0 ) + ret = 0; + else + { + mtrr_del_page(ret, 0, 0); + ret = -EFAULT; + } } } break; @@ -96,8 +101,10 @@ long do_platform_op(XEN_GUEST_HANDLE(xen op->u.read_memtype.mfn = mfn; op->u.read_memtype.nr_mfns = nr_mfns; op->u.read_memtype.type = type; - (void)copy_to_guest(u_xenpf_op, op, 1); - ret = 0; + if ( copy_to_guest(u_xenpf_op, op, 1) == 0 ) + ret = 0; + else + ret = -EFAULT; } } break;