mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
stm class: Fix stm device initialization order
[ Upstream commit 389b6699a2 ]
Currently, stm_register_device() makes the device visible and then
proceeds to initializing spinlocks and other properties, which leaves
a window when the device can already be opened but is not yet fully
operational.
Fix this by reversing the initialization order.
Reported-by: Alan Cox <alan.cox@intel.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Laurent Fert <laurent.fert@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
2040e80d80
commit
b0351a51ff
@@ -664,6 +664,18 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
|
||||
stm->dev.parent = parent;
|
||||
stm->dev.release = stm_device_release;
|
||||
|
||||
mutex_init(&stm->link_mutex);
|
||||
spin_lock_init(&stm->link_lock);
|
||||
INIT_LIST_HEAD(&stm->link_list);
|
||||
|
||||
/* initialize the object before it is accessible via sysfs */
|
||||
spin_lock_init(&stm->mc_lock);
|
||||
mutex_init(&stm->policy_mutex);
|
||||
stm->sw_nmasters = nmasters;
|
||||
stm->owner = owner;
|
||||
stm->data = stm_data;
|
||||
stm_data->stm = stm;
|
||||
|
||||
err = kobject_set_name(&stm->dev.kobj, "%s", stm_data->name);
|
||||
if (err)
|
||||
goto err_device;
|
||||
@@ -672,17 +684,6 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
|
||||
if (err)
|
||||
goto err_device;
|
||||
|
||||
mutex_init(&stm->link_mutex);
|
||||
spin_lock_init(&stm->link_lock);
|
||||
INIT_LIST_HEAD(&stm->link_list);
|
||||
|
||||
spin_lock_init(&stm->mc_lock);
|
||||
mutex_init(&stm->policy_mutex);
|
||||
stm->sw_nmasters = nmasters;
|
||||
stm->owner = owner;
|
||||
stm->data = stm_data;
|
||||
stm_data->stm = stm;
|
||||
|
||||
return 0;
|
||||
|
||||
err_device:
|
||||
|
||||
Reference in New Issue
Block a user