sk-queue: dump_sk_creds -- Don't leak memory for SkUcredEntry

When error happened in dump_sk_creds or dumping
in dump_sk_queue passed fine we can leak xmalloc'ed
SkUcredEntry. Fix it.

Note it's not critical anyhow since CRIU will end up
execution in both cases and OS release memory
automatically but still.

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
(cherry picked from commit 969a2aba0331ff940501205077766859453b9a35)
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
This commit is contained in:
Cyrill Gorcunov 2017-03-01 14:43:44 +03:00 committed by Alexander Mikhalitsyn
parent d77eb99d2a
commit abc025016b

View file

@ -153,7 +153,7 @@ static int dump_sk_creds(struct ucred *ucred, SkPacketEntry *pe, int flags)
* because virt pid-s are known for dumped task only
*/
pr_err("ucred-s for unix sockets aren't supported yet\n");
return -1;
goto out;
} else {
int pidns = root_ns_mask & CLONE_NEWPID;
char path[64];
@ -171,13 +171,17 @@ static int dump_sk_creds(struct ucred *ucred, SkPacketEntry *pe, int flags)
}
if (ret) {
pr_err("Unable to dump ucred for a dead process %d\n", ucred->pid);
return -1;
goto out;
}
ent->pid = ucred->pid;
}
pe->ucred = ent;
return 0;
out:
xfree(ent);
return -1;
}
static int dump_packet_cmsg(struct msghdr *mh, SkPacketEntry *pe, int flags)
@ -361,6 +365,7 @@ err_set_sock:
if (pe.scm)
release_cmsg(&pe);
err_brk:
xfree(pe.ucred);
xfree(data);
return ret;
}