Skip to content

Commit 382dd99

Browse files
committed
libmpathutil: runner: pause in cleanup handler if rctx is NULL
In this (more or less impossible) case, make sure that pthread_cancel() can't access invalid memory because the thread has exited unexpectedly. Signed-off-by: Martin Wilck <mwilck@suse.com>
1 parent 9f0bd43 commit 382dd99

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

libmpathutil/runner.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <sched.h>
55
#include <time.h>
66
#include <pthread.h>
7+
#include <unistd.h>
78
#include <urcu/uatomic.h>
89
#include "util.h"
910
#include "debug.h"
@@ -44,8 +45,10 @@ static void cleanup_context(struct runner_context **prctx)
4445
struct runner_context *rctx = *prctx;
4546
int st;
4647

47-
if (!rctx)
48-
return;
48+
if (!rctx) {
49+
condlog(0, "ERROR: %s: rctx is NULL", __func__);
50+
pause();
51+
}
4952

5053
st = uatomic_cmpxchg(&rctx->status, RUNNER_RUNNING, RUNNER_DONE);
5154
/*

0 commit comments

Comments
 (0)