]> git.proxmox.com Git - mirror_qemu.git/blobdiff - linux-user/flatload.c
Fix input-linux reading from device
[mirror_qemu.git] / linux-user / flatload.c
index 48ad1c5e9e3ee17062680c036f9e025f57e93b06..a35a560904917d086e52b97c8294e1d3e2d52e55 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "qemu.h"
 #include "flat.h"
-#include <target_flat.h>
+#include "target_flat.h"
 
 //#define DEBUG
 
@@ -95,7 +95,13 @@ static int target_pread(int fd, abi_ulong ptr, abi_ulong len,
     int ret;
 
     buf = lock_user(VERIFY_WRITE, ptr, len, 0);
+    if (!buf) {
+        return -EFAULT;
+    }
     ret = pread(fd, buf, len, offset);
+    if (ret < 0) {
+        ret = -errno;
+    }
     unlock_user(buf, ptr, len);
     return ret;
 }