[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/4] libvduse: Check the return value of some ioctls
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 4/4] libvduse: Check the return value of some ioctls |
Date: |
Wed, 29 Jun 2022 11:41:53 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
Xie Yongji <xieyongji@bytedance.com> writes:
> Coverity pointed out (CID 1490222, 1490227) that we called
> ioctl somewhere without checking the return value. This
> patch fixes these issues.
>
> Fixes: Coverity CID 1490222, 1490227
> Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
> ---
> subprojects/libvduse/libvduse.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
> index 1a5981445c..bf7302c60a 100644
> --- a/subprojects/libvduse/libvduse.c
> +++ b/subprojects/libvduse/libvduse.c
> @@ -947,7 +947,10 @@ static void vduse_queue_disable(VduseVirtq *vq)
>
> eventfd.index = vq->index;
> eventfd.fd = VDUSE_EVENTFD_DEASSIGN;
> - ioctl(dev->fd, VDUSE_VQ_SETUP_KICKFD, &eventfd);
> + if (ioctl(dev->fd, VDUSE_VQ_SETUP_KICKFD, &eventfd)) {
> + fprintf(stderr, "Failed to disable eventfd for vq[%d]: %s\n",
> + vq->index, strerror(errno));
> + }
> close(vq->fd);
>
> assert(vq->inuse == 0);
> @@ -1337,7 +1340,10 @@ VduseDev *vduse_dev_create(const char *name, uint32_t
> device_id,
>
> return dev;
> err:
> - ioctl(ctrl_fd, VDUSE_DESTROY_DEV, name);
> + if (ioctl(ctrl_fd, VDUSE_DESTROY_DEV, name)) {
> + fprintf(stderr, "Failed to destroy vduse device %s: %s\n",
> + name, strerror(errno));
> + }
> err_dev:
> close(ctrl_fd);
> err_ctrl:
Both errors are during cleanup that can't fail. The program continues
as if they didn't happen. Does the user need to know?
- [PATCH 2/4] libvduse: Replace strcpy() with strncpy(), (continued)
- [PATCH 2/4] libvduse: Replace strcpy() with strncpy(), Xie Yongji, 2022/06/27
- [PATCH 1/4] libvduse: Fix the incorrect function name, Xie Yongji, 2022/06/27
- [PATCH 3/4] libvduse: Pass positive value to strerror(), Xie Yongji, 2022/06/27
- [PATCH 4/4] libvduse: Check the return value of some ioctls, Xie Yongji, 2022/06/27
- Re: [PATCH 4/4] libvduse: Check the return value of some ioctls,
Markus Armbruster <=
- Re: [PATCH 4/4] libvduse: Check the return value of some ioctls, Yongji Xie, 2022/06/29
- Re: [PATCH 4/4] libvduse: Check the return value of some ioctls, Markus Armbruster, 2022/06/29
- Re: [PATCH 4/4] libvduse: Check the return value of some ioctls, Yongji Xie, 2022/06/29
- Re: [PATCH 4/4] libvduse: Check the return value of some ioctls, Markus Armbruster, 2022/06/29
- Re: [PATCH 4/4] libvduse: Check the return value of some ioctls, Yongji Xie, 2022/06/29