summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormjg <mjg@FreeBSD.org>2016-06-02 15:52:34 +0000
committermjg <mjg@FreeBSD.org>2016-06-02 15:52:34 +0000
commit2175f886b3d33082d1516ca4a3cafa27fc922007 (patch)
tree2ae207723fe86123bb43b6f6e9dd11cfa7a6dbb4
parent944327caa7d255376a656b6a1646a3a6403a81ae (diff)
downloadFreeBSD-src-2175f886b3d33082d1516ca4a3cafa27fc922007.zip
FreeBSD-src-2175f886b3d33082d1516ca4a3cafa27fc922007.tar.gz
taskqueue: plug a leak in _taskqueue_create
While here make some style fixes and postpone the sprintf so that it is only done when the function can no longer fail. CID: 1356041
-rw-r--r--sys/kern/subr_taskqueue.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c
index 00cb46f..4be29f5 100644
--- a/sys/kern/subr_taskqueue.c
+++ b/sys/kern/subr_taskqueue.c
@@ -130,14 +130,16 @@ _taskqueue_create(const char *name, int mflags,
char *tq_name;
tq_name = malloc(TASKQUEUE_NAMELEN, M_TASKQUEUE, mflags | M_ZERO);
- if (!tq_name)
+ if (tq_name == NULL)
return (NULL);
- snprintf(tq_name, TASKQUEUE_NAMELEN, "%s", (name) ? name : "taskqueue");
-
queue = malloc(sizeof(struct taskqueue), M_TASKQUEUE, mflags | M_ZERO);
- if (!queue)
+ if (queue == NULL) {
+ free(tq_name, M_TASKQUEUE);
return (NULL);
+ }
+
+ snprintf(tq_name, TASKQUEUE_NAMELEN, "%s", (name) ? name : "taskqueue");
STAILQ_INIT(&queue->tq_queue);
TAILQ_INIT(&queue->tq_active);
OpenPOWER on IntegriCloud