summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>2026-03-30 10:07:57 +0300
committerThomas Gleixner <tglx@kernel.org>2026-04-01 18:13:35 +0300
commit6d89dc8b1c559ee2662db86f7490ac52cab3030c (patch)
tree01b1b84d0b1818f2bc09986303f8004208041fff
parent3fa3aeb4a5cb19e372680ef8860a0381cd5409e9 (diff)
downloadlinux-6d89dc8b1c559ee2662db86f7490ac52cab3030c.tar.xz
timens: Use mutex guard in proc_timens_set_offset()
Simplify the logic in proc_timens_set_offset() by converting the mutex usage to a guard(). Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/20260330-timens-cleanup-v1-3-936e91c9dd30@linutronix.de
-rw-r--r--kernel/time/namespace.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c
index 37495bde92a4..084ceec35495 100644
--- a/kernel/time/namespace.c
+++ b/kernel/time/namespace.c
@@ -270,7 +270,7 @@ int proc_timens_set_offset(struct file *file, struct task_struct *p,
struct time_namespace *time_ns __free(time_ns) = NULL;
struct ns_common *ns = timens_for_children_get(p);
struct timespec64 tp;
- int i, err;
+ int i;
if (!ns)
return -ESRCH;
@@ -307,13 +307,10 @@ int proc_timens_set_offset(struct file *file, struct task_struct *p,
return -ERANGE;
}
- mutex_lock(&timens_offset_lock);
- if (time_ns->frozen_offsets) {
- err = -EACCES;
- goto out_unlock;
- }
+ guard(mutex)(&timens_offset_lock);
+ if (time_ns->frozen_offsets)
+ return -EACCES;
- err = 0;
/* Don't report errors after this line */
for (i = 0; i < noffsets; i++) {
struct proc_timens_offset *off = &offsets[i];
@@ -331,10 +328,7 @@ int proc_timens_set_offset(struct file *file, struct task_struct *p,
*offset = off->val;
}
-out_unlock:
- mutex_unlock(&timens_offset_lock);
-
- return err;
+ return 0;
}
const struct proc_ns_operations timens_operations = {