mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
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
This commit is contained in:
parent
6761eb4b11
commit
f3c8e16ea5
1 changed files with 6 additions and 4 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue