[dpdk-dev,1/1] vhost: fix null pointer dereference
Commit Message
Return value of function get_device() is not checking before
dereference. Fix this problem by adding checking condition.
Coverity issue: 119262
Fixes: 77d20126b4c2 ("vhost-user: handle message to enable vring")
Signed-off-by: Marcin Kerlin <marcinx.kerlin@intel.com>
---
lib/librte_vhost/vhost_user/virtio-net-user.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Comments
On Wed, Jun 15, 2016 at 11:47:22AM +0200, Marcin Kerlin wrote:
> Return value of function get_device() is not checking before
> dereference. Fix this problem by adding checking condition.
>
> Coverity issue: 119262
> Fixes: 77d20126b4c2 ("vhost-user: handle message to enable vring")
>
> Signed-off-by: Marcin Kerlin <marcinx.kerlin@intel.com>
Applied to dpdk-next-virtio.
Thanks.
--yliu
@@ -332,9 +332,13 @@ int
user_set_vring_enable(struct vhost_device_ctx ctx,
struct vhost_vring_state *state)
{
- struct virtio_net *dev = get_device(ctx);
+ struct virtio_net *dev;
int enable = (int)state->num;
+ dev = get_device(ctx);
+ if (dev == NULL)
+ return -1;
+
RTE_LOG(INFO, VHOST_CONFIG,
"set queue enable: %d to qp idx: %d\n",
enable, state->index);