aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-08-22 13:55:56 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2012-08-28 01:50:02 -0500
commitc068d37020f8c0d10beaf4671c41b05b923d7896 (patch)
tree05c593b24884445dc7690b309eb19270ed48117d
parentcc5caf7df4ed5833183121e08c6b6131722137d5 (diff)
softmmu-semi: fix lock_user* functions not to deref NULL upon OOM
Return NULL upon malloc failure. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit 15d9e3bc6af8a56af8c61911aab8453a54795db1) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--softmmu-semi.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/softmmu-semi.h b/softmmu-semi.h
index 648cb959d..bcb979a5b 100644
--- a/softmmu-semi.h
+++ b/softmmu-semi.h
@@ -40,7 +40,7 @@ static void *softmmu_lock_user(CPUArchState *env, uint32_t addr, uint32_t len,
uint8_t *p;
/* TODO: Make this something that isn't fixed size. */
p = malloc(len);
- if (copy)
+ if (p && copy)
cpu_memory_rw_debug(env, addr, p, len, 0);
return p;
}
@@ -52,6 +52,9 @@ static char *softmmu_lock_user_string(CPUArchState *env, uint32_t addr)
uint8_t c;
/* TODO: Make this something that isn't fixed size. */
s = p = malloc(1024);
+ if (!s) {
+ return NULL;
+ }
do {
cpu_memory_rw_debug(env, addr, &c, 1, 0);
addr++;