Skip to content

Commit

Permalink
dm: validate inputs in vq_endchains
Browse files Browse the repository at this point in the history
 inputs shall be validated to avoid NULL pointer access.

Tracked-On: #6129
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
  • Loading branch information
yonghuah authored and wenlingz committed Jun 8, 2021
1 parent 25c0e38 commit 154fe59
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions devicemodel/hw/pci/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,9 @@ vq_endchains(struct virtio_vq_info *vq, int used_all_avail)
uint16_t event_idx, new_idx, old_idx;
int intr;

if (!vq || !vq->used)
return;

/*
* Interrupt generation: if we're using EVENT_IDX,
* interrupt if we've crossed the event threshold.
Expand Down

0 comments on commit 154fe59

Please sign in to comment.