On 2020/12/29 ??7:53, Eli Cohen wrote:>> +
>> +static struct vhost_vdpa_as *vhost_vdpa_alloc_as(struct vhost_vdpa *v,
u32 asid)
>> +{
>> + struct hlist_head *head = &v->as[asid %
VHOST_VDPA_IOTLB_BUCKETS];
>> + struct vhost_vdpa_as *as;
>> +
>> + if (asid_to_as(v, asid))
>> + return NULL;
>> +
>> + as = kmalloc(sizeof(*as), GFP_KERNEL);
> kzalloc()? See comment below.
>
>> + if (!as)
>> + return NULL;
>> +
>> + vhost_iotlb_init(&as->iotlb, 0, 0);
>> + as->id = asid;
>> + hlist_add_head(&as->hash_link, head);
>> + ++v->used_as;
> Although you eventually ended up removing used_as, this is a bug since
> you're incrementing a random value. Maybe it's better to be on the
safe
> side and use kzalloc() for as above.
Yes and used_as needs to be removed.
Thanks
>