stm class: Fix stm device initialization order
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>
This commit is contained in:
parent
cbe4a61d1d
commit
389b6699a2
|
@ -666,6 +666,18 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
|
||||||
stm->dev.parent = parent;
|
stm->dev.parent = parent;
|
||||||
stm->dev.release = stm_device_release;
|
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);
|
err = kobject_set_name(&stm->dev.kobj, "%s", stm_data->name);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_device;
|
goto err_device;
|
||||||
|
@ -674,17 +686,6 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
|
||||||
if (err)
|
if (err)
|
||||||
goto err_device;
|
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;
|
return 0;
|
||||||
|
|
||||||
err_device:
|
err_device:
|
||||||
|
|
Loading…
Reference in New Issue