Message ID | 20230127131636.20889-1-laurentiu.tudor@nxp.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | bus: fsl-mc: don't assume child devices are all fsl-mc devices | expand |
On Fri, Jan 27, 2023 at 03:16:36PM +0200, laurentiu.tudor@nxp.com wrote: > From: Laurentiu Tudor <laurentiu.tudor@nxp.com> > > Changes in VFIO caused a pseudo-device to be created as child of > fsl-mc devices causing a crash [1] when trying to bind a fsl-mc > device to VFIO. Fix this by checking the device type when enumerating > fsl-mc child devices. What changes? What commit id does this fix? Does it need to be backported? And what type of "pseudo device" is being created? Why would it be passed to this driver if it's the wrong type? this feels wrong... thanks, greg k-h
Hi Greg, On 1/31/2023 1:56 PM, Greg KH wrote: > On Fri, Jan 27, 2023 at 03:16:36PM +0200, laurentiu.tudor@nxp.com wrote: >> From: Laurentiu Tudor <laurentiu.tudor@nxp.com> >> >> Changes in VFIO caused a pseudo-device to be created as child of >> fsl-mc devices causing a crash [1] when trying to bind a fsl-mc >> device to VFIO. Fix this by checking the device type when enumerating >> fsl-mc child devices. > > What changes? What commit id does this fix? Does it need to be > backported? There were a lot of changes in the VFIO area but I'd point at this commit [1]. I'll resend the patch with a "Fixes:" tag pointing at this commit if that's ok with you. > And what type of "pseudo device" is being created? > Why would it be passed to this driver if it's the wrong type? It's not passed to the driver per-se. The problem shows up when the implementation of the driver does a device_for_each_child() [2] and the callback blindly assumes that all enumerated children devices are fsl-mc devices. The patch just adds a check for this case. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3c28a76124b25882411f005924be73795b6ef078 [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/bus/fsl-mc/dprc-driver.c?#n96 --- Thanks & Best Regards, Laurentiu
On Wed, Feb 01, 2023 at 01:50:11PM +0200, Laurentiu Tudor wrote: > Hi Greg, > > On 1/31/2023 1:56 PM, Greg KH wrote: > > On Fri, Jan 27, 2023 at 03:16:36PM +0200, laurentiu.tudor@nxp.com wrote: > > > From: Laurentiu Tudor <laurentiu.tudor@nxp.com> > > > > > > Changes in VFIO caused a pseudo-device to be created as child of > > > fsl-mc devices causing a crash [1] when trying to bind a fsl-mc > > > device to VFIO. Fix this by checking the device type when enumerating > > > fsl-mc child devices. > > > > What changes? What commit id does this fix? Does it need to be > > backported? > > There were a lot of changes in the VFIO area but I'd point at this commit > [1]. > > I'll resend the patch with a "Fixes:" tag pointing at this commit if that's > ok with you. Please do. > > And what type of "pseudo device" is being created? Why would it be > > passed to this driver if it's the wrong type? > > It's not passed to the driver per-se. The problem shows up when the > implementation of the driver does a device_for_each_child() [2] and the > callback blindly assumes that all enumerated children devices are fsl-mc > devices. The patch just adds a check for this case. Ah, that makes more sense, sorry for the noise. greg k-h
diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c index 4c84be378bf2..ec5f26a45641 100644 --- a/drivers/bus/fsl-mc/dprc-driver.c +++ b/drivers/bus/fsl-mc/dprc-driver.c @@ -45,6 +45,9 @@ static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data) struct fsl_mc_child_objs *objs; struct fsl_mc_device *mc_dev; + if (!dev_is_fsl_mc(dev)) + return 0; + mc_dev = to_fsl_mc_device(dev); objs = data; @@ -64,6 +67,9 @@ static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data) static int __fsl_mc_device_remove(struct device *dev, void *data) { + if (!dev_is_fsl_mc(dev)) + return 0; + fsl_mc_device_remove(to_fsl_mc_device(dev)); return 0; }