aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhanghailiang <zhang.zhanghailiang@huawei.com>2014-08-14 15:29:15 +0800
committerMichael Tokarev <mjt@tls.msk.ru>2014-08-15 19:12:58 +0400
commit5edbdbcdf882e4220adc7dbf433351077cd1fbbc (patch)
tree533517c9628d4009668cdaab3371d622cfdafc15
parent2c145d7a73206afc576fea86514e892e11481dab (diff)
ivshmem: check the value returned by fstat()
The function fstat() may fail, so check its return value. Acked-by: Levente Kurusa <lkurusa@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r--hw/misc/ivshmem.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 768e5288bc..2be4b86726 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -324,7 +324,11 @@ static int check_shm_size(IVShmemState *s, int fd) {
struct stat buf;
- fstat(fd, &buf);
+ if (fstat(fd, &buf) < 0) {
+ fprintf(stderr, "ivshmem: exiting: fstat on fd %d failed: %s\n",
+ fd, strerror(errno));
+ return -1;
+ }
if (s->ivshmem_size > buf.st_size) {
fprintf(stderr,