lkml.org 
[lkml]   [2020]   [Dec]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 11/21] vhost-vdpa: introduce asid based IOTLB
From
Date

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



>

\
 
 \ /
  Last update: 2020-12-30 07:38    [W:0.073 / U:25.464 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site