Revision 6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25 authored by Florian Fainelli on 09 February 2017, 03:05:26 UTC, committed by David S. Miller on 09 February 2017, 21:22:12 UTC
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: cafe8df8b9bc ("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>
1 parent 075ad76
History
File Mode Size
partitions
Kconfig -rw-r--r-- 4.9 KB
Kconfig.iosched -rw-r--r-- 1.6 KB
Makefile -rw-r--r-- 1.0 KB
badblocks.c -rw-r--r-- 14.5 KB
bio-integrity.c -rw-r--r-- 14.3 KB
bio.c -rw-r--r-- 49.9 KB
blk-cgroup.c -rw-r--r-- 35.8 KB
blk-core.c -rw-r--r-- 92.3 KB
blk-exec.c -rw-r--r-- 3.2 KB
blk-flush.c -rw-r--r-- 16.4 KB
blk-integrity.c -rw-r--r-- 12.3 KB
blk-ioc.c -rw-r--r-- 10.2 KB
blk-lib.c -rw-r--r-- 9.9 KB
blk-map.c -rw-r--r-- 5.9 KB
blk-merge.c -rw-r--r-- 19.4 KB
blk-mq-cpumap.c -rw-r--r-- 2.3 KB
blk-mq-pci.c -rw-r--r-- 1.5 KB
blk-mq-sysfs.c -rw-r--r-- 12.9 KB
blk-mq-tag.c -rw-r--r-- 11.1 KB
blk-mq-tag.h -rw-r--r-- 2.2 KB
blk-mq.c -rw-r--r-- 63.7 KB
blk-mq.h -rw-r--r-- 2.9 KB
blk-settings.c -rw-r--r-- 28.2 KB
blk-softirq.c -rw-r--r-- 4.3 KB
blk-stat.c -rw-r--r-- 5.9 KB
blk-stat.h -rw-r--r-- 1.1 KB
blk-sysfs.c -rw-r--r-- 22.6 KB
blk-tag.c -rw-r--r-- 10.0 KB
blk-throttle.c -rw-r--r-- 42.7 KB
blk-timeout.c -rw-r--r-- 5.9 KB
blk-wbt.c -rw-r--r-- 17.6 KB
blk-wbt.h -rw-r--r-- 3.9 KB
blk-zoned.c -rw-r--r-- 7.6 KB
blk.h -rw-r--r-- 9.0 KB
bounce.c -rw-r--r-- 5.8 KB
bsg-lib.c -rw-r--r-- 6.4 KB
bsg.c -rw-r--r-- 22.9 KB
cfq-iosched.c -rw-r--r-- 127.1 KB
cmdline-parser.c -rw-r--r-- 4.9 KB
compat_ioctl.c -rw-r--r-- 20.8 KB
deadline-iosched.c -rw-r--r-- 11.3 KB
elevator.c -rw-r--r-- 23.7 KB
genhd.c -rw-r--r-- 45.0 KB
ioctl.c -rw-r--r-- 15.1 KB
ioprio.c -rw-r--r-- 5.1 KB
noop-iosched.c -rw-r--r-- 2.6 KB
partition-generic.c -rw-r--r-- 16.6 KB
scsi_ioctl.c -rw-r--r-- 19.5 KB
t10-pi.c -rw-r--r-- 4.8 KB

back to top