net/virtio_user: do not close invalid file descriptor
Checks
Commit Message
Valgrind complains that virtio_user is calling close(-1).
Fix this by adding check in virtio that is similar to existing code.
Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer")
Cc: jianfeng.tan@intel.com
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Mon, Jan 06, 2020 at 11:18:37AM -0800, Stephen Hemminger wrote:
> Valgrind complains that virtio_user is calling close(-1).
> Fix this by adding check in virtio that is similar to existing code.
>
> Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer")
> Cc: jianfeng.tan@intel.com
> Cc: stable@dpdk.org
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
On 1/7/20 2:41 AM, Tiwei Bie wrote:
> On Mon, Jan 06, 2020 at 11:18:37AM -0800, Stephen Hemminger wrote:
>> Valgrind complains that virtio_user is calling close(-1).
>> Fix this by adding check in virtio that is similar to existing code.
>>
>> Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer")
>> Cc: jianfeng.tan@intel.com
>> Cc: stable@dpdk.org
>> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>> ---
>> drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
>
Applied to dpdk-next-virtio/master.
Thanks,
Maxime
@@ -537,7 +537,8 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
close(dev->kickfds[i]);
}
- close(dev->vhostfd);
+ if (dev->vhostfd >= 0)
+ close(dev->vhostfd);
if (dev->is_server && dev->listenfd >= 0) {
close(dev->listenfd);