63 lines
1.8 KiB
Diff
63 lines
1.8 KiB
Diff
From 2c651d3ed5e7d7d78338ce542e66ee9fb36a9275 Mon Sep 17 00:00:00 2001
|
|
From: zhongtao <zhongtao17@huawei.com>
|
|
Date: Sun, 14 May 2023 14:25:22 +0800
|
|
Subject: [PATCH 4/9] ensure isulad_io not NULL before close fd
|
|
|
|
Signed-off-by: zhongtao <zhongtao17@huawei.com>
|
|
---
|
|
src/cmd/isulad-shim/process.c | 28 ++++++++++++++++------------
|
|
1 file changed, 16 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/src/cmd/isulad-shim/process.c b/src/cmd/isulad-shim/process.c
|
|
index 7716c288..6ad50c53 100644
|
|
--- a/src/cmd/isulad-shim/process.c
|
|
+++ b/src/cmd/isulad-shim/process.c
|
|
@@ -194,6 +194,10 @@ static int stdin_cb(int fd, uint32_t events, void *cbdata, struct epoll_descr *d
|
|
} else {
|
|
fd_to = &(p->shim_io->in);
|
|
}
|
|
+
|
|
+ if (fd_to == NULL || *fd_to == -1) {
|
|
+ return EPOLL_LOOP_HANDLE_CONTINUE;
|
|
+ }
|
|
w_count = write_nointr_in_total(*fd_to, p->buf, r_count);
|
|
if (w_count < 0) {
|
|
/* When any error occurs, set the write fd -1 */
|
|
@@ -797,21 +801,21 @@ static int init_isulad_stdio(process_t *p)
|
|
return SHIM_OK;
|
|
failure:
|
|
if (p->isulad_io != NULL) {
|
|
+ if (p->isulad_io->in > 0) {
|
|
+ close(p->isulad_io->in);
|
|
+ }
|
|
+ if (p->isulad_io->out > 0) {
|
|
+ close(p->isulad_io->out);
|
|
+ }
|
|
+ if (p->isulad_io->err > 0) {
|
|
+ close(p->isulad_io->err);
|
|
+ }
|
|
+ if (p->isulad_io->resize > 0) {
|
|
+ close(p->isulad_io->resize);
|
|
+ }
|
|
free(p->isulad_io);
|
|
p->isulad_io = NULL;
|
|
}
|
|
- if (p->isulad_io->in > 0) {
|
|
- close(p->isulad_io->in);
|
|
- }
|
|
- if (p->isulad_io->out > 0) {
|
|
- close(p->isulad_io->out);
|
|
- }
|
|
- if (p->isulad_io->err > 0) {
|
|
- close(p->isulad_io->err);
|
|
- }
|
|
- if (p->isulad_io->resize > 0) {
|
|
- close(p->isulad_io->resize);
|
|
- }
|
|
return SHIM_ERR;
|
|
}
|
|
|
|
--
|
|
2.40.1
|
|
|