On Fri, 12 Mar 2021 20:55:59 -0400 Jason Gunthorpe <jgg@xxxxxxxxxx> wrote: > vfio_pci_probe() is quite complicated, with optional VF and VGA sub > components. Move these into clear init/uninit functions and have a linear > flow in probe/remove. > > This fixes a few little buglets: > - vfio_pci_remove() is in the wrong order, vga_client_register() removes > a notifier and is after kfree(vdev), but the notifier refers to vdev, > so it can use after free in a race. > - vga_client_register() can fail but was ignored > > Organize things so destruction order is the reverse of creation order. > > Fixes: ecaa1f6a0154 ("vfio-pci: Add VGA arbiter client") > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx> > --- > drivers/vfio/pci/vfio_pci.c | 116 +++++++++++++++++++++++------------- > 1 file changed, 74 insertions(+), 42 deletions(-) Reviewed-by: Cornelia Huck <cohuck@xxxxxxxxxx>