]> git.baikalelectronics.ru Git - kernel.git/commit
vfio/fsl-mc: Re-order vfio_fsl_mc_probe()
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 30 Mar 2021 15:53:06 +0000 (09:53 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 6 Apr 2021 17:55:10 +0000 (11:55 -0600)
commitae898c018600ade6ebbab1a1b662cddceed4ba1b
tree701a50ccc922ed6cc440402ebe9d9ffa57c31239
parentda81920101ba07634d7b407c3d2aea8d805ee3fb
vfio/fsl-mc: Re-order vfio_fsl_mc_probe()

vfio_add_group_dev() must be called only after all of the private data in
vdev is fully setup and ready, otherwise there could be races with user
space instantiating a device file descriptor and starting to call ops.

For instance vfio_fsl_mc_reflck_attach() sets vdev->reflck and
vfio_fsl_mc_open(), called by fops open, unconditionally derefs it, which
will crash if things get out of order.

This driver started life with the right sequence, but two commits added
stuff after vfio_add_group_dev().

Fixes: 4bbc1a6b2ae9 ("vfio/fsl-mc: Add irq infrastructure for fsl-mc devices")
Fixes: f9e0b6cf3712 ("vfio/fsl-mc: Added lock support in preparation for interrupt handling")
Co-developed-by: Diana Craciun OSS <diana.craciun@oss.nxp.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Message-Id: <5-v3-225de1400dfc+4e074-vfio1_jgg@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/fsl-mc/vfio_fsl_mc.c