Files
linux/drivers/net
Florian Fainelli 3a6ebd3f96 net: phy: Fix PHY module checks and NULL deref in phy_attach_direct()
[ Upstream commit 6d9f66ac7f ]

The Generic PHY drivers gets assigned after we checked that the current
PHY driver is NULL, so we need to check a few things before we can
safely dereference d->driver. This would be causing a NULL deference to
occur when a system binds to the Generic PHY driver. Update
phy_attach_direct() to do the following:

- grab the driver module reference after we have assigned the Generic
  PHY drivers accordingly, and remember we came from the generic PHY
  path

- update the error path to clean up the module reference in case the
  Generic PHY probe function fails

- split the error path involving phy_detacht() to avoid double free/put
  since phy_detach() does all the clean up

- finally, have phy_detach() drop the module reference count before we
  call device_release_driver() for the Generic PHY driver case

Fixes: cafe8df8b9 ("net: phy: Fix lack of reference count on PHY driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-17 06:41:52 +02:00
..
2016-06-15 22:06:06 -07:00
2016-08-15 11:57:55 -07:00
2017-06-17 06:41:50 +02:00
2016-08-31 14:33:09 -07:00
2017-03-22 12:43:32 +01:00
2016-05-09 00:00:28 -04:00
2016-09-20 22:55:23 -04:00
2017-02-18 15:11:42 +01:00
2016-04-26 15:53:05 -04:00
2016-08-30 22:27:18 -07:00
2017-06-14 15:05:52 +02:00