mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-23 01:59:04 +00:00
fsnotify: Fix memory leak in pre_dump_one_fanotify error path
When irmap_queue_cache fails, the remaining fanotify mark entries and the mark array are not freed, causing a memory leak. Add cleanup label to ensure proper deallocation of remaining entries and the mark array on error paths. Signed-off-by: 3idey <elaidya225@gmail.com>
This commit is contained in:
parent
06348103d6
commit
dd2fb045a9
1 changed files with 8 additions and 3 deletions
|
|
@ -476,7 +476,7 @@ free:
|
|||
static int pre_dump_one_fanotify(int pid, int lfd)
|
||||
{
|
||||
FanotifyFileEntry fe = FANOTIFY_FILE_ENTRY__INIT;
|
||||
int i;
|
||||
int i, ret = -1;
|
||||
|
||||
if (parse_fdinfo_pid(pid, lfd, FD_TYPES__FANOTIFY, &fe)) {
|
||||
pr_err("Failed to parse fdinfo for fanotify (pid %d lfd %d)\n", pid, lfd);
|
||||
|
|
@ -489,13 +489,18 @@ static int pre_dump_one_fanotify(int pid, int lfd)
|
|||
if (me->type == MARK_TYPE__INODE && irmap_queue_cache(me->s_dev, me->ie->i_ino, me->ie->f_handle)) {
|
||||
pr_err("Failed to queue irmap cache for fanotify mark (dev %#x ino %#" PRIx64 " mask %#x)\n",
|
||||
me->s_dev, me->ie->i_ino, me->mask);
|
||||
return -1;
|
||||
goto err;
|
||||
}
|
||||
|
||||
xfree(me);
|
||||
}
|
||||
|
||||
return 0;
|
||||
ret = 0;
|
||||
err:
|
||||
for (; i < fe.n_mark; i++)
|
||||
xfree(fe.mark[i]);
|
||||
xfree(fe.mark);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const struct fdtype_ops fanotify_dump_ops = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue