On Tue, 23 Mar 2021 14:55:25 -0300 Jason Gunthorpe <jgg@xxxxxxxxxx> wrote: > Once the memory for the struct mdev_device is allocated it should > immediately be device_initialize()'d and filled in so that put_device() > can always be used to undo the allocation. > > Place the mdev_get/put_parent() so that they are clearly protecting the > mdev->parent pointer. Move the final put to the release function so that > the lifetime rules are trivial to understand. > > Remove mdev_device_free() as the release function via device_put() is now > usable in all cases. > > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx> > --- > drivers/vfio/mdev/mdev_core.c | 46 +++++++++++++++-------------------- > 1 file changed, 20 insertions(+), 26 deletions(-) Reviewed-by: Cornelia Huck <cohuck@xxxxxxxxxx>