hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/autofs/waitq.c
....@@ -1,10 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
34 * Copyright 2001-2006 Ian Kent <raven@themaw.net>
4
- *
5
- * This file is part of the Linux kernel and is made available under
6
- * the terms of the GNU General Public License, version 2, or at your
7
- * option, any later version, incorporated herein by reference.
85 */
96
107 #include <linux/sched/signal.h>
....@@ -20,14 +17,14 @@
2017 struct autofs_wait_queue *wq, *nwq;
2118
2219 mutex_lock(&sbi->wq_mutex);
23
- if (sbi->catatonic) {
20
+ if (sbi->flags & AUTOFS_SBI_CATATONIC) {
2421 mutex_unlock(&sbi->wq_mutex);
2522 return;
2623 }
2724
2825 pr_debug("entering catatonic mode\n");
2926
30
- sbi->catatonic = 1;
27
+ sbi->flags |= AUTOFS_SBI_CATATONIC;
3128 wq = sbi->queues;
3229 sbi->queues = NULL; /* Erase all wait queues */
3330 while (wq) {
....@@ -35,8 +32,9 @@
3532 wq->status = -ENOENT; /* Magic is gone - report failure */
3633 kfree(wq->name.name);
3734 wq->name.name = NULL;
38
- wq->wait_ctr--;
3935 wake_up_interruptible(&wq->queue);
36
+ if (!--wq->wait_ctr)
37
+ kfree(wq);
4038 wq = nwq;
4139 }
4240 fput(sbi->pipe); /* Close the pipe */
....@@ -56,7 +54,7 @@
5654
5755 mutex_lock(&sbi->pipe_mutex);
5856 while (bytes) {
59
- wr = __kernel_write(file, data, bytes, &file->f_pos);
57
+ wr = __kernel_write(file, data, bytes, NULL);
6058 if (wr <= 0)
6159 break;
6260 data += wr;
....@@ -255,7 +253,7 @@
255253 struct autofs_wait_queue *wq;
256254 struct autofs_info *ino;
257255
258
- if (sbi->catatonic)
256
+ if (sbi->flags & AUTOFS_SBI_CATATONIC)
259257 return -ENOENT;
260258
261259 /* Wait in progress, continue; */
....@@ -290,7 +288,7 @@
290288 if (mutex_lock_interruptible(&sbi->wq_mutex))
291289 return -EINTR;
292290
293
- if (sbi->catatonic)
291
+ if (sbi->flags & AUTOFS_SBI_CATATONIC)
294292 return -ENOENT;
295293
296294 wq = autofs_find_wait(sbi, qstr);
....@@ -359,7 +357,7 @@
359357 pid_t tgid;
360358
361359 /* In catatonic mode, we don't wait for nobody */
362
- if (sbi->catatonic)
360
+ if (sbi->flags & AUTOFS_SBI_CATATONIC)
363361 return -ENOENT;
364362
365363 /*