From mboxrd@z Thu Jan 1 00:00:00 1970 From: Diego Ongaro Subject: [PATCH] gnttab_setup_table error case Date: Wed, 30 Jul 2008 14:17:39 +0100 Message-ID: <489069F3.7070200@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: 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 gnttab_setup_table should set an error status code if the gmfn it gets for a grant table page is invalid. I ran into this issue when I tried to set up the grant table during hvm domain creation, and it caused a BUG_ON later down the line. With this patch, the hypercall will gracefully fail instead. Signed-off-by: Diego Ongaro --- diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -913,8 +913,15 @@ gnttab_setup_table( op.status = GNTST_okay; for ( i = 0; i < op.nr_frames; i++ ) { gmfn = gnttab_shared_gmfn(d, d->grant_table, i); + if ( gmfn == -1 ) + { + gdprintk(XENLOG_INFO, + "grant table gmfn unavailable\n"); + op.status = GNTST_general_error; + goto out3; + } (void)copy_to_guest_offset(op.frame_list, i, &gmfn, 1); } out3: