Skip to content

Commit 434ac47

Browse files
committed
Merge tag 'driver-core-3.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core / sysfs fixes from Greg KH: "Here are 2 fixes for 3.12-rc3. One fixes a sysfs problem with mounting caused by 3.12-rc1, and the other is a bug reported by the chromeos developers with the driver core. Both have been in linux-next for a bit" * tag 'driver-core-3.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: driver core : Fix use after free of dev->parent in device_shutdown sysfs: Allow mounting without CONFIG_NET
2 parents c23c223 + f123db8 commit 434ac47

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/base/core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,7 @@ EXPORT_SYMBOL_GPL(device_move);
20172017
*/
20182018
void device_shutdown(void)
20192019
{
2020-
struct device *dev;
2020+
struct device *dev, *parent;
20212021

20222022
spin_lock(&devices_kset->list_lock);
20232023
/*
@@ -2034,7 +2034,7 @@ void device_shutdown(void)
20342034
* prevent it from being freed because parent's
20352035
* lock is to be held
20362036
*/
2037-
get_device(dev->parent);
2037+
parent = get_device(dev->parent);
20382038
get_device(dev);
20392039
/*
20402040
* Make sure the device is off the kset list, in the
@@ -2044,8 +2044,8 @@ void device_shutdown(void)
20442044
spin_unlock(&devices_kset->list_lock);
20452045

20462046
/* hold lock to avoid race with probe/release */
2047-
if (dev->parent)
2048-
device_lock(dev->parent);
2047+
if (parent)
2048+
device_lock(parent);
20492049
device_lock(dev);
20502050

20512051
/* Don't allow any more runtime suspends */
@@ -2063,11 +2063,11 @@ void device_shutdown(void)
20632063
}
20642064

20652065
device_unlock(dev);
2066-
if (dev->parent)
2067-
device_unlock(dev->parent);
2066+
if (parent)
2067+
device_unlock(parent);
20682068

20692069
put_device(dev);
2070-
put_device(dev->parent);
2070+
put_device(parent);
20712071

20722072
spin_lock(&devices_kset->list_lock);
20732073
}

0 commit comments

Comments
 (0)