mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-23 10:09:57 +00:00
fsnotify: Fix memory leak in pre_dump_one_inotify error path
When irmap_queue_cache fails, the remaining inotify watch descriptors and the wd array are not freed, causing a memory leak. Add cleanup label to ensure proper deallocation of remaining entries and the wd array on error paths. Signed-off-by: 3idey <elaidya225@gmail.com>
This commit is contained in:
parent
14b325e36f
commit
06348103d6
1 changed files with 8 additions and 3 deletions
|
|
@ -364,7 +364,7 @@ free:
|
|||
static int pre_dump_one_inotify(int pid, int lfd)
|
||||
{
|
||||
InotifyFileEntry ie = INOTIFY_FILE_ENTRY__INIT;
|
||||
int i;
|
||||
int i, ret = -1;
|
||||
|
||||
if (parse_fdinfo_pid(pid, lfd, FD_TYPES__INOTIFY, &ie)) {
|
||||
pr_err("Failed to parse fdinfo for inotify (pid %d lfd %d)\n", pid, lfd);
|
||||
|
|
@ -377,13 +377,18 @@ static int pre_dump_one_inotify(int pid, int lfd)
|
|||
if (irmap_queue_cache(we->s_dev, we->i_ino, we->f_handle)) {
|
||||
pr_err("Failed to queue irmap cache for inotify wd %#x (dev %#x ino %#" PRIx64 ")\n",
|
||||
we->wd, we->s_dev, we->i_ino);
|
||||
return -1;
|
||||
goto err;
|
||||
}
|
||||
|
||||
xfree(we);
|
||||
}
|
||||
|
||||
return 0;
|
||||
ret = 0;
|
||||
err:
|
||||
for (; i < ie.n_wd; i++)
|
||||
xfree(ie.wd[i]);
|
||||
xfree(ie.wd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const struct fdtype_ops inotify_dump_ops = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue