> > On driver removal, the platform_device_unregister call > > attached through devm_add_action_or_reset was executed > > after usb_hcd_pci_remove. > > This lead to a use-after-free for the iomem resource of > > the xhci-ext-caps driver in the platform removal > > because the parent of the resource was freed earlier. > > > > Fix this by using devm for hcd-pci created resources. > > This simplifies error handling on driver initialisation > > and fixes the removal sequence. > > > > Signed-off-by: Carsten Schmid <carsten_schmid@xxxxxxxxxx> > > Tested-by: Carsten Schmid <carsten_schmid@xxxxxxxxxx> > > --- > > Thanks, code looks good to me. > > But as this is no longer a xhci specific fix I'm not sure if this > commit message is generic enough. > > Could be worth explaining that using managed device resources > in usb_hcd_pci_probe() allows devm usage for resource subranges, such > as the mmio resource for the platform device created to control host/device > mode mux, which is a xhci extended capability, and sits inside the xhci mmio > region. > > If managed device resources are not used then "parent" resource > is released before subrange at driver removal as .remove callback is > called before the devres list of resources for this device is walked > and released > > -Mathias > I agree, this covers more than the fix i originally have in mind. May i use/cite your "could be worth explaining" above for the commit message? (of course, a bit adapted :-) ) And: i would like replace the commit title again to read: usb: hcd: use managed device resources Ok for you? BR Carsten