diff --git a/libs/libc/misc/lib_fdcheck.c b/libs/libc/misc/lib_fdcheck.c index f14d3b751da..2119eb11813 100644 --- a/libs/libc/misc/lib_fdcheck.c +++ b/libs/libc/misc/lib_fdcheck.c @@ -63,6 +63,7 @@ static uint8_t g_fdcheck_tag = 0; int fdcheck_restore(int val) { uint8_t tag_store; + int ret; int fd; /* If val is a bare fd(0~255), we should return it directly */ @@ -73,7 +74,7 @@ int fdcheck_restore(int val) return val; } - int ret = ioctl(fd, FIOC_GETTAG_FDCHECK, &tag_store); + ret = ioctl(fd, FIOC_GETTAG_FDCHECK, &tag_store); if (ret >= 0) { uint8_t tag_expect = (val >> TAG_SHIFT) & TAG_MASK; @@ -84,6 +85,12 @@ int fdcheck_restore(int val) PANIC(); } } + else + { + ferr("fd is bad, or fd have already been closed, errno:%d", + get_errno()); + PANIC(); + } return fd; }