|
14 | 14 | #include <linux/acpi.h>
|
15 | 15 | #include <linux/errno.h>
|
16 | 16 | #include <linux/fs.h>
|
| 17 | +#include <linux/mutex.h> |
17 | 18 | #include <linux/string.h>
|
18 | 19 | #include <linux/types.h>
|
19 | 20 | #include <linux/dmi.h>
|
@@ -195,6 +196,7 @@ static const char * const level_options[] = {
|
195 | 196 | };
|
196 | 197 | static struct think_lmi tlmi_priv;
|
197 | 198 | static struct class *fw_attr_class;
|
| 199 | +static DEFINE_MUTEX(tlmi_mutex); |
198 | 200 |
|
199 | 201 | /* ------ Utility functions ------------*/
|
200 | 202 | /* Strip out CR if one is present */
|
@@ -437,6 +439,9 @@ static ssize_t new_password_store(struct kobject *kobj,
|
437 | 439 | /* Strip out CR if one is present, setting password won't work if it is present */
|
438 | 440 | strip_cr(new_pwd);
|
439 | 441 |
|
| 442 | + /* Use lock in case multiple WMI operations needed */ |
| 443 | + mutex_lock(&tlmi_mutex); |
| 444 | + |
440 | 445 | pwdlen = strlen(new_pwd);
|
441 | 446 | /* pwdlen == 0 is allowed to clear the password */
|
442 | 447 | if (pwdlen && ((pwdlen < setting->minlen) || (pwdlen > setting->maxlen))) {
|
@@ -493,6 +498,7 @@ static ssize_t new_password_store(struct kobject *kobj,
|
493 | 498 | kfree(auth_str);
|
494 | 499 | }
|
495 | 500 | out:
|
| 501 | + mutex_unlock(&tlmi_mutex); |
496 | 502 | kfree(new_pwd);
|
497 | 503 | return ret ?: count;
|
498 | 504 | }
|
@@ -981,6 +987,9 @@ static ssize_t current_value_store(struct kobject *kobj,
|
981 | 987 | /* Strip out CR if one is present */
|
982 | 988 | strip_cr(new_setting);
|
983 | 989 |
|
| 990 | + /* Use lock in case multiple WMI operations needed */ |
| 991 | + mutex_lock(&tlmi_mutex); |
| 992 | + |
984 | 993 | /* Check if certificate authentication is enabled and active */
|
985 | 994 | if (tlmi_priv.certificate_support && tlmi_priv.pwd_admin->cert_installed) {
|
986 | 995 | if (!tlmi_priv.pwd_admin->signature || !tlmi_priv.pwd_admin->save_signature) {
|
@@ -1039,6 +1048,7 @@ static ssize_t current_value_store(struct kobject *kobj,
|
1039 | 1048 | kobject_uevent(&tlmi_priv.class_dev->kobj, KOBJ_CHANGE);
|
1040 | 1049 | }
|
1041 | 1050 | out:
|
| 1051 | + mutex_unlock(&tlmi_mutex); |
1042 | 1052 | kfree(auth_str);
|
1043 | 1053 | kfree(set_str);
|
1044 | 1054 | kfree(new_setting);
|
|
0 commit comments