> Thanks for fixing this, this is an improvement, though I can still hit > another sort of use after free whereby the GENET driver removes the > mdio-bcm-unimac platform device and eventually cuts the clock to the MDIO > block thus causing the following: Hi Florian Yes, i was not expecting this patch to fix that. But i was getting the NULL pointer dereference you pointed out with another setup, and this change does fix that part of the problem. > still not clear to me how the workqueue managed to execute and not finish > before we unregistered the PHY device. Me neither. I took a look at the MDIO bus driver and could not see anything obvious. I think you are going to have to scatter printk() in the code to get a clear understanding of the order things are done. Maybe it is another devm_ timing issue. Andrew