Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/linux linux: Paranoia: Don't read kt_s...



details:   https://anonhg.NetBSD.org/src/rev/9c9c3336fc5a
branches:  trunk
changeset: 1028887:9c9c3336fc5a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 12:24:19 2021 +0000

description:
linux: Paranoia: Don't read kt_shouldstop unlocked.

diffstat:

 sys/external/bsd/drm2/linux/linux_kthread.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r 43a984d7547e -r 9c9c3336fc5a sys/external/bsd/drm2/linux/linux_kthread.c
--- a/sys/external/bsd/drm2/linux/linux_kthread.c       Sun Dec 19 12:24:12 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_kthread.c       Sun Dec 19 12:24:19 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_kthread.c,v 1.1 2021/12/19 12:23:07 riastradh Exp $      */
+/*     $NetBSD: linux_kthread.c,v 1.2 2021/12/19 12:24:19 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.1 2021/12/19 12:23:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.2 2021/12/19 12:24:19 riastradh Exp $");
 
 #include <sys/types.h>
 
@@ -171,8 +171,14 @@
 int
 kthread_should_stop(void)
 {
+       struct task_struct *T = linux_kthread();
+       bool shouldstop;
 
-       return linux_kthread()->kt_shouldstop;
+       mutex_enter(&T->kt_lock);
+       shouldstop = T->kt_shouldstop;
+       mutex_exit(&T->kt_lock);
+
+       return shouldstop;
 }
 
 void



Home | Main Index | Thread Index | Old Index