On 3/15/21 4:50 PM, David Marchand wrote:
> On Mon, Mar 15, 2021 at 4:20 PM Maxime Coquelin
> <maxime.coque...@redhat.com> wrote:
>> @@ -550,10 +551,18 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t
>> queue_idx)
>> goto free_hdr_mz;
>> }
>>
>> + fake_mbuf = malloc(sizeof(*fake_mbuf));
>> + if (!fake_mbuf) {
>> + PMD_INIT_LOG(ERR, "can not allocate fake mbuf");
>> + ret = -ENOMEM;
>> + goto free_sw_ring;
>> + }
>> +
>> vq->sw_ring = sw_ring;
>> rxvq = &vq->rxq;
>> rxvq->port_id = dev->data->port_id;
>> rxvq->mz = mz;
>> + rxvq->fake_mbuf = fake_mbuf;
>
> IIRC, vq is allocated as dpdk memory (rte_malloc).
> Generally speaking, storing a local pointer inside such an object is
> dangerous if other processes start to look at this part.
Agree, I will change to rte_zmalloc_socket, as vq (which is was part of)
is allocated like that.
Thanks,
Maxime
>
>> } else if (queue_type == VTNET_TQ) {
>> txvq = &vq->txq;
>> txvq->port_id = dev->data->port_id;
>> @@ -613,6 +622,9 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t
>> queue_idx)
>> clean_vq:
>> hw->cvq = NULL;
>>
>> + if (fake_mbuf)
>> + free(fake_mbuf);
>
> No need for if().
>
>