virtio: fix potential memory leak in virtio_dev_init
When device was reinitialized, the old virtqueue memory used to leak. While here, also added a doc for virtio_dev_init. Change-Id: I9bb8dbfa5d68deeb73e71567a7e51b82f869537a Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/388297 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
222ebc1912
commit
84eb1451ea
@ -263,6 +263,10 @@ virtio_alloc_queues(struct virtio_dev *dev)
|
|||||||
uint16_t i;
|
uint16_t i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (dev->vqs != NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
dev->vqs = rte_zmalloc(NULL, sizeof(struct virtqueue *) * nr_vq, 0);
|
dev->vqs = rte_zmalloc(NULL, sizeof(struct virtqueue *) * nr_vq, 0);
|
||||||
if (!dev->vqs) {
|
if (!dev->vqs) {
|
||||||
SPDK_ERRLOG("failed to allocate %"PRIu16" vqs\n", nr_vq);
|
SPDK_ERRLOG("failed to allocate %"PRIu16" vqs\n", nr_vq);
|
||||||
@ -329,7 +333,6 @@ struct virtio_dev *
|
|||||||
return vdev;
|
return vdev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset device and renegotiate features if needed */
|
|
||||||
int
|
int
|
||||||
virtio_dev_init(struct virtio_dev *dev, uint64_t req_features)
|
virtio_dev_init(struct virtio_dev *dev, uint64_t req_features)
|
||||||
{
|
{
|
||||||
|
@ -218,7 +218,13 @@ int virtio_xmit_pkt(struct virtqueue *vq, struct virtio_req *req);
|
|||||||
*/
|
*/
|
||||||
struct virtio_dev *virtio_dev_construct(const struct virtio_dev_ops *ops, void *ctx);
|
struct virtio_dev *virtio_dev_construct(const struct virtio_dev_ops *ops, void *ctx);
|
||||||
|
|
||||||
int virtio_dev_init(struct virtio_dev *hw, uint64_t req_features);
|
/**
|
||||||
|
* Reset and reinit a virtio device. This will also renegotiate feature flags.
|
||||||
|
*
|
||||||
|
* \param vdev vhost device
|
||||||
|
* \param req_features features this driver supports
|
||||||
|
*/
|
||||||
|
int virtio_dev_init(struct virtio_dev *vdev, uint64_t req_features);
|
||||||
void virtio_dev_free(struct virtio_dev *dev);
|
void virtio_dev_free(struct virtio_dev *dev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user