aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrusty@rustcorp.com.au[kaf24] <rusty@rustcorp.com.au[kaf24]>2005-05-12 10:33:58 +0000
committerrusty@rustcorp.com.au[kaf24] <rusty@rustcorp.com.au[kaf24]>2005-05-12 10:33:58 +0000
commit3b0a5597b094d5ee236f101e6e8f0f1608642d6a (patch)
tree9ad51aa344d2fcafc4f0b9597c36beff42944906
parentec8f5e583c1f8db7141c279663da34714e1caf77 (diff)
downloadxen-3b0a5597b094d5ee236f101e6e8f0f1608642d6a.tar.gz
xen-3b0a5597b094d5ee236f101e6e8f0f1608642d6a.tar.bz2
xen-3b0a5597b094d5ee236f101e6e8f0f1608642d6a.zip
bitkeeper revision 1.1389.19.5 (42833116hOft6cekTRSGqSIk2tNzGA)
[PATCH] [PATCH] libxc: mmap doesn't return NULL on error... Hi, was reading libxc code, and noticed this. Patch is bigger than strictly necessary due to indent adjust. Against latest bk. Rusty.
-rw-r--r--BitKeeper/etc/logging_ok1
-rw-r--r--tools/libxc/xc.h2
-rw-r--r--tools/libxc/xc_private.c46
3 files changed, 25 insertions, 24 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index 379ce87a72..3cdc0126d1 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -80,6 +80,7 @@ rn@wyvis.camb.intel-research.net
rn@wyvis.research.intel-research.net
rneugeba@wyvis.research
rneugeba@wyvis.research.intel-research.net
+rusty@rustcorp.com.au
ryanh@us.ibm.com
sd386@font.cl.cam.ac.uk
shand@spidean.research.intel-research.net
diff --git a/tools/libxc/xc.h b/tools/libxc/xc.h
index 913581fe9d..3b464eb683 100644
--- a/tools/libxc/xc.h
+++ b/tools/libxc/xc.h
@@ -421,7 +421,7 @@ int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
/**
* Memory maps a range within one domain to a local address range. Mappings
* should be unmapped with munmap and should follow the same rules as mmap
- * regarding page alignment.
+ * regarding page alignment. Returns NULL on failure.
*
* In Linux, the ring queue for the control channel is accessible by mapping
* the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
index 39318bc4fa..550989e3e0 100644
--- a/tools/libxc/xc_private.c
+++ b/tools/libxc/xc_private.c
@@ -13,18 +13,18 @@ void *xc_map_foreign_batch(int xc_handle, u32 dom, int prot,
privcmd_mmapbatch_t ioctlx;
void *addr;
addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0);
- if ( addr != NULL )
+ if ( addr == MAP_FAILED )
+ return NULL;
+
+ ioctlx.num=num;
+ ioctlx.dom=dom;
+ ioctlx.addr=(unsigned long)addr;
+ ioctlx.arr=arr;
+ if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx ) < 0 )
{
- ioctlx.num=num;
- ioctlx.dom=dom;
- ioctlx.addr=(unsigned long)addr;
- ioctlx.arr=arr;
- if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx ) < 0 )
- {
- perror("XXXXXXXX");
- munmap(addr, num*PAGE_SIZE);
- return 0;
- }
+ perror("XXXXXXXX");
+ munmap(addr, num*PAGE_SIZE);
+ return NULL;
}
return addr;
@@ -40,19 +40,19 @@ void *xc_map_foreign_range(int xc_handle, u32 dom,
privcmd_mmap_entry_t entry;
void *addr;
addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0);
- if ( addr != NULL )
+ if ( addr == MAP_FAILED )
+ return NULL;
+
+ ioctlx.num=1;
+ ioctlx.dom=dom;
+ ioctlx.entry=&entry;
+ entry.va=(unsigned long) addr;
+ entry.mfn=mfn;
+ entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT;
+ if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx ) < 0 )
{
- ioctlx.num=1;
- ioctlx.dom=dom;
- ioctlx.entry=&entry;
- entry.va=(unsigned long) addr;
- entry.mfn=mfn;
- entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT;
- if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx ) < 0 )
- {
- munmap(addr, size);
- return 0;
- }
+ munmap(addr, size);
+ return NULL;
}
return addr;
}