]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86/intel/tpmi: convert mutex in mem_write() to guard
authorZhaoJinming <zhaojinming@uniontech.com>
Thu, 21 May 2026 13:08:48 +0000 (21:08 +0800)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 9 Jun 2026 11:54:34 +0000 (14:54 +0300)
Convert the explicit mutex_lock/mutex_unlock pair in mem_write() into
a cleanup.h guard(mutex)() scope-based lock acquisition. This removes
the remaining goto-based cleanup path and keeps the lock held until
the end of the mem_write() scope.

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: ZhaoJinming <zhaojinming@uniontech.com>
Link: https://patch.msgid.link/20260521130848.2860219-2-zhaojinming@uniontech.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel/vsec_tpmi.c

index 3b76cccb975f6bc854be5b061ce85df7d42e1ce8..0153dd57838e70dc8a1be42a159aaac3f7f26899 100644 (file)
@@ -504,24 +504,17 @@ static ssize_t mem_write(struct file *file, const char __user *userbuf, size_t l
        if (addr >= size)
                return -EINVAL;
 
-       mutex_lock(&tpmi_dev_lock);
+       guard(mutex)(&tpmi_dev_lock);
 
        mem = ioremap(pfs->vsec_offset + punit * size, size);
-       if (!mem) {
-               ret = -ENOMEM;
-               goto unlock_mem_write;
-       }
+       if (!mem)
+               return -ENOMEM;
 
        writel(value, mem + addr);
 
        iounmap(mem);
 
-       ret = len;
-
-unlock_mem_write:
-       mutex_unlock(&tpmi_dev_lock);
-
-       return ret;
+       return len;
 }
 
 static int mem_write_show(struct seq_file *s, void *unused)