Skip to content

Commit f582757

Browse files
lyan3wenlingz
authored andcommitted
tools: acrn-manager: fix fd leaking
close dir to avoid fd leaking. Tracked-On: #1477 Signed-off-by: Tao, Yuhong <yuhong.tao@intel.com> Signed-off-by: Yan, Like <like.yan@intel.com>
1 parent dc05fff commit f582757

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

tools/acrn-manager/acrn_mngr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ static int connect_to_server(const char *name)
484484
if ((ret >= 0) && (ret < strlen(s_name)))
485485
printf("WARN: %s is truncated\n", s_name);
486486

487-
closedir(dir);
488487
ret =
489488
connect(mfd->fd, (struct sockaddr *)&mfd->addr, sizeof(mfd->addr));
490489
if (ret < 0) {
@@ -499,6 +498,7 @@ static int connect_to_server(const char *name)
499498
goto alloc_val;
500499
}
501500

501+
closedir(dir);
502502
return ret;
503503

504504
alloc_val:
@@ -507,6 +507,7 @@ static int connect_to_server(const char *name)
507507
sock_err:
508508
free(mfd);
509509
alloc_mfd:
510+
closedir(dir);
510511
return ret;
511512
}
512513

tools/acrn-manager/acrn_vm_ops.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ static void _scan_alive_vm(void)
150150
vm->update = update_count;
151151
}
152152

153+
closedir(dir);
153154
}
154155

155156
static void _scan_added_vm(void)
@@ -218,6 +219,8 @@ static void _scan_added_vm(void)
218219
vm->state = VM_CREATED;
219220
vm->update = update_count;
220221
}
222+
223+
closedir(dir);
221224
}
222225

223226
static void _remove_dead_vm(void)

0 commit comments

Comments
 (0)