diff options
-rw-r--r-- | security/tomoyo/common.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c index 7556315c1978..2b7b1a123600 100644 --- a/security/tomoyo/common.c +++ b/security/tomoyo/common.c | |||
@@ -459,8 +459,16 @@ static int tomoyo_write_profile(struct tomoyo_io_buffer *head) | |||
459 | if (profile == &tomoyo_default_profile) | 459 | if (profile == &tomoyo_default_profile) |
460 | return -EINVAL; | 460 | return -EINVAL; |
461 | if (!strcmp(data, "COMMENT")) { | 461 | if (!strcmp(data, "COMMENT")) { |
462 | const struct tomoyo_path_info *old_comment = profile->comment; | 462 | static DEFINE_SPINLOCK(lock); |
463 | profile->comment = tomoyo_get_name(cp); | 463 | const struct tomoyo_path_info *new_comment |
464 | = tomoyo_get_name(cp); | ||
465 | const struct tomoyo_path_info *old_comment; | ||
466 | if (!new_comment) | ||
467 | return -ENOMEM; | ||
468 | spin_lock(&lock); | ||
469 | old_comment = profile->comment; | ||
470 | profile->comment = new_comment; | ||
471 | spin_unlock(&lock); | ||
464 | tomoyo_put_name(old_comment); | 472 | tomoyo_put_name(old_comment); |
465 | return 0; | 473 | return 0; |
466 | } | 474 | } |