vhost: check hugepage fstat error
authorHuawei Xie <huawei.xie@intel.com>
Tue, 14 Jun 2016 17:45:23 +0000 (01:45 +0800)
committerYuanhan Liu <yuanhan.liu@linux.intel.com>
Wed, 22 Jun 2016 07:47:12 +0000 (09:47 +0200)
commit2cdc118eef96d1c92c2ddae82dd4b04a30eb78e4
tree3ae27a9a97dc08acc36e0d3346c337083f5e576d
parent428261b4615ecc69672b19df8b0e535a380c04d1
vhost: check hugepage fstat error

Value returned from fstat is not checked for errors before being used.
This patch fixes following coverity issue.

    static uint64_t
    get_blk_size(int fd)
    {
     struct stat stat;

     fstat(fd, &stat);
     return (uint64_t)stat.st_blksize;
    >>>  CID 107103 (#1 of 1): Unchecked return value from library
         (CHECKED_RETURN)
    >>>  check_return: Calling fstat(fd, &stat) without checking
         return value.
    >>>  This library function may fail and return an error code.

Fixes: 8f972312b8f4 ("vhost: support vhost-user")

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
lib/librte_vhost/vhost_user/virtio-net-user.c