diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c index b370b372c788..2ef5a3c1ea65 100644 --- a/sys/kern/subr_taskqueue.c +++ b/sys/kern/subr_taskqueue.c @@ -128,16 +128,17 @@ _taskqueue_create(const char *name, int mflags, int mtxflags, const char *mtxname __unused) { struct taskqueue *queue; - char *tq_name = NULL; + char *tq_name; - if (name != NULL) - tq_name = strndup(name, 32, M_TASKQUEUE); - if (tq_name == NULL) - tq_name = "taskqueue"; + tq_name = malloc(TASKQUEUE_NAMELEN, M_TASKQUEUE, mflags | M_ZERO); + if (!tq_name) + return (NULL); + + snprintf(tq_name, TASKQUEUE_NAMELEN, "%s", (name) ? name : "taskqueue"); queue = malloc(sizeof(struct taskqueue), M_TASKQUEUE, mflags | M_ZERO); if (!queue) - return NULL; + return (NULL); STAILQ_INIT(&queue->tq_queue); TAILQ_INIT(&queue->tq_active); @@ -153,7 +154,7 @@ _taskqueue_create(const char *name, int mflags, queue->tq_flags |= TQ_FLAGS_UNLOCKED_ENQUEUE; mtx_init(&queue->tq_mutex, tq_name, NULL, mtxflags); - return queue; + return (queue); } struct taskqueue * diff --git a/sys/sys/taskqueue.h b/sys/sys/taskqueue.h index 432a75e69518..bc01088dacfc 100644 --- a/sys/sys/taskqueue.h +++ b/sys/sys/taskqueue.h @@ -56,6 +56,7 @@ enum taskqueue_callback_type { #define TASKQUEUE_CALLBACK_TYPE_MIN TASKQUEUE_CALLBACK_TYPE_INIT #define TASKQUEUE_CALLBACK_TYPE_MAX TASKQUEUE_CALLBACK_TYPE_SHUTDOWN #define TASKQUEUE_NUM_CALLBACKS TASKQUEUE_CALLBACK_TYPE_MAX + 1 +#define TASKQUEUE_NAMELEN 32 typedef void (*taskqueue_callback_fn)(void *context);