Re: Re: [RFC PATCH 13/15] virtio-mem: Handle virtio_device_ready() failure
From: Yongji Xie
Date: Mon May 17 2021 - 06:08:27 EST
On Mon, May 17, 2021 at 5:48 PM David Hildenbrand <david@xxxxxxxxxx> wrote:
>
> On 17.05.21 11:34, Xie Yongji wrote:
> > Now virtio_device_ready() will return error if we get
> > invalid status. Let's handle this case on probe.
> >
> > Signed-off-by: Xie Yongji <xieyongji@xxxxxxxxxxxxx>
> > ---
> > drivers/virtio/virtio_mem.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
> > index 32a8e359a5c3..1148c392ff94 100644
> > --- a/drivers/virtio/virtio_mem.c
> > +++ b/drivers/virtio/virtio_mem.c
> > @@ -2602,13 +2602,17 @@ static int virtio_mem_probe(struct virtio_device *vdev)
> > if (rc)
> > goto out_unreg_mem;
> >
> > - virtio_device_ready(vdev);
> > + rc = virtio_device_ready(vdev);
> > + if (rc)
> > + goto out_unreg_device;
> >
> > /* trigger a config update to start processing the requested_size */
> > atomic_set(&vm->config_changed, 1);
> > queue_work(system_freezable_wq, &vm->wq);
> >
> > return 0;
> > +out_unreg_device:
> > + unregister_virtio_mem_device(vm);
> > out_unreg_mem:
> > unregister_memory_notifier(&vm->memory_notifier);
> > out_del_resource:
> >
>
> I assume this will really be a corner case to hit, right?
>
Yes, it should almost never happen if the device is trusted.
Thanks,
Yongji