mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-17 16:47:50 +00:00
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:
parent
d77eb99d2a
commit
abc025016b
1 changed files with 7 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue