From 02463a2c7370251a412f8b5f1a221ee002681634 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 4 Jul 2018 10:16:18 -0400 Subject: [PATCH] freebsd11_network: Handle NULL gracefully instead of faulting. FreeBSD does not have these checks, but drivers seem to expect that they can call these functions with NULL and not crash. Fixes a number of boot-failure tickets (and makes it possible for me at least to test drivers without rebooting from KDL every failure), though of course the drivers themselves will still not work. --- src/libs/compat/freebsd11_network/callout.cpp | 5 +++++ src/libs/compat/freebsd11_network/taskqueue.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/libs/compat/freebsd11_network/callout.cpp b/src/libs/compat/freebsd11_network/callout.cpp index c80938b63e..3548ec8494 100644 --- a/src/libs/compat/freebsd11_network/callout.cpp +++ b/src/libs/compat/freebsd11_network/callout.cpp @@ -212,6 +212,11 @@ _callout_stop_safe(struct callout *c, int safe) { MutexLocker locker(sLock); + if (c == NULL) { + printf("_callout_stop_safe called with NULL callout"); + return 0; + } + TRACE("_callout_stop_safe %p, func %p, arg %p\n", c, c->c_func, c->c_arg); if (c->due <= 0) diff --git a/src/libs/compat/freebsd11_network/taskqueue.c b/src/libs/compat/freebsd11_network/taskqueue.c index 94b78a6641..89c7cbefac 100644 --- a/src/libs/compat/freebsd11_network/taskqueue.c +++ b/src/libs/compat/freebsd11_network/taskqueue.c @@ -247,6 +247,11 @@ taskqueue_drain(struct taskqueue *taskQueue, struct task *task) { cpu_status status; + if (taskQueue == NULL) { + printf("taskqueue_drain called with NULL taskqueue"); + return; + } + tq_lock(taskQueue, &status); while (task->ta_pending != 0) { tq_unlock(taskQueue, status);