diff options
Diffstat (limited to 'pfinet/io-ops.c')
-rw-r--r-- | pfinet/io-ops.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/pfinet/io-ops.c b/pfinet/io-ops.c index 21bc3ac2..ef8d8513 100644 --- a/pfinet/io-ops.c +++ b/pfinet/io-ops.c @@ -87,6 +87,11 @@ S_io_read (struct sock_user *user, if (amount > *datalen) { *data = mmap (0, amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + if (*data == MAP_FAILED) + /* Should check whether errno is indeed ENOMEM -- + but this can't be done in a straightforward way, + because the glue headers #undef errno. */ + return ENOMEM; alloced = 1; } @@ -102,7 +107,11 @@ S_io_read (struct sock_user *user, __mutex_unlock (&global_lock); if (err < 0) - err = -err; + { + err = -err; + if (alloced) + munmap (*data, amount); + } else { *datalen = err; |