mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-13 12:49:35 +02:00
crypto: qat - extend scope of lock in adf_cfg_add_key_value_param()
[ Upstream commit6424da7d8b
] The function adf_cfg_add_key_value_param() attempts to access and modify the key value store of the driver without locking. Extend the scope of cfg->lock to avoid a potential race condition. Fixes:92bf269fbf
("crypto: qat - change behaviour of adf_cfg_add_key_value_param()") Signed-off-by: Nivas Varadharajan Mugunthakumar <nivasx.varadharajan.mugunthakumar@intel.com> Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
846ee3b60a
commit
adbaa8f99c
|
@ -290,17 +290,19 @@ int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev,
|
||||||
* 3. if the key exists with the same value, then return without doing
|
* 3. if the key exists with the same value, then return without doing
|
||||||
* anything (the newly created key_val is freed).
|
* anything (the newly created key_val is freed).
|
||||||
*/
|
*/
|
||||||
|
down_write(&cfg->lock);
|
||||||
if (!adf_cfg_key_val_get(accel_dev, section_name, key, temp_val)) {
|
if (!adf_cfg_key_val_get(accel_dev, section_name, key, temp_val)) {
|
||||||
if (strncmp(temp_val, key_val->val, sizeof(temp_val))) {
|
if (strncmp(temp_val, key_val->val, sizeof(temp_val))) {
|
||||||
adf_cfg_keyval_remove(key, section);
|
adf_cfg_keyval_remove(key, section);
|
||||||
} else {
|
} else {
|
||||||
kfree(key_val);
|
kfree(key_val);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
down_write(&cfg->lock);
|
|
||||||
adf_cfg_keyval_add(key_val, section);
|
adf_cfg_keyval_add(key_val, section);
|
||||||
|
|
||||||
|
out:
|
||||||
up_write(&cfg->lock);
|
up_write(&cfg->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user