mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
vhost-vdpa: initialize state before publishing cdev
Initialize the completion and as hash buckets before cdev_device_add()
makes the device accessible.
Fixes: 4c8cf31885 ("vhost: introduce vDPA-based backend")
Assisted-by: OpenAI-Codex:GPT-5.6
Signed-off-by: Linfeng Sun <linfeng.sun.dev@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20261011-fix-null-pointer-in-vhost_vdpa_release-v2-1-66ba929971ce@gmail.com>
This commit is contained in:
parent
509f6bd229
commit
4b03d1e7f1
|
|
@ -1699,7 +1699,7 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa)
|
|||
return minor;
|
||||
}
|
||||
|
||||
atomic_set(&v->opened, 0);
|
||||
atomic_set(&v->opened, 1);
|
||||
spin_lock_init(&v->config_lock);
|
||||
v->minor = minor;
|
||||
v->vdpa = vdpa;
|
||||
|
|
@ -1722,16 +1722,17 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa)
|
|||
|
||||
cdev_init(&v->cdev, &vhost_vdpa_fops);
|
||||
v->cdev.owner = THIS_MODULE;
|
||||
init_completion(&v->completion);
|
||||
for (i = 0; i < VHOST_VDPA_IOTLB_BUCKETS; i++)
|
||||
INIT_HLIST_HEAD(&v->as[i]);
|
||||
|
||||
r = cdev_device_add(&v->cdev, &v->dev);
|
||||
if (r)
|
||||
goto err;
|
||||
|
||||
init_completion(&v->completion);
|
||||
vdpa_set_drvdata(vdpa, v);
|
||||
|
||||
for (i = 0; i < VHOST_VDPA_IOTLB_BUCKETS; i++)
|
||||
INIT_HLIST_HEAD(&v->as[i]);
|
||||
atomic_set_release(&v->opened, 0);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user