aboutsummaryrefslogtreecommitdiff
path: root/target/arm/arm-semi.c
diff options
context:
space:
mode:
Diffstat (limited to 'target/arm/arm-semi.c')
-rw-r--r--target/arm/arm-semi.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
index 47d61f6fe1..788fe61b51 100644
--- a/target/arm/arm-semi.c
+++ b/target/arm/arm-semi.c
@@ -144,7 +144,8 @@ static int alloc_guestfd(void)
guestfd_array = g_array_new(FALSE, TRUE, sizeof(GuestFD));
}
- for (i = 0; i < guestfd_array->len; i++) {
+ /* SYS_OPEN should return nonzero handle on success. Start guestfd from 1 */
+ for (i = 1; i < guestfd_array->len; i++) {
GuestFD *gf = &g_array_index(guestfd_array, GuestFD, i);
if (gf->type == GuestFDUnused) {
@@ -168,7 +169,7 @@ static GuestFD *do_get_guestfd(int guestfd)
return NULL;
}
- if (guestfd < 0 || guestfd >= guestfd_array->len) {
+ if (guestfd <= 0 || guestfd >= guestfd_array->len) {
return NULL;
}