Skip to content

Commit

Permalink
vhost: fix fd leak in dirty logging setup
Browse files Browse the repository at this point in the history
[ upstream commit 6dc3f11 ]

This patch fixes a file descriptor leak which happens
in the error path of vhost_user_set_log_base().

Fixes: 4796ad6 ("examples/vhost: import userspace vhost application")

Reported-by: Xuan Ding <xuan.ding@intel.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Xueming Li <xuemingl@nvidia.com>
  • Loading branch information
mcoquelin authored and kevintraynor committed Nov 23, 2020
1 parent 36b1fdd commit 34ed9a3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/librte_vhost/vhost_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg,
RTE_LOG(ERR, VHOST_CONFIG,
"invalid log base msg size: %"PRId32" != %d\n",
msg->size, (int)sizeof(VhostUserLog));
return VH_RESULT_ERR;
goto close_msg_fds;
}

size = msg->payload.log.mmap_size;
Expand All @@ -1619,7 +1619,7 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg,
RTE_LOG(ERR, VHOST_CONFIG,
"log offset %#"PRIx64" and log size %#"PRIx64" overflow\n",
off, size);
return VH_RESULT_ERR;
goto close_msg_fds;
}

RTE_LOG(INFO, VHOST_CONFIG,
Expand Down Expand Up @@ -1656,6 +1656,10 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg,
msg->fd_num = 0;

return VH_RESULT_REPLY;

close_msg_fds:
close_msg_fds(msg);
return VH_RESULT_ERR;
}

static int vhost_user_set_log_fd(struct virtio_net **pdev __rte_unused,
Expand Down

0 comments on commit 34ed9a3

Please sign in to comment.