fix(stdio): check close_p return before decrementing fd count

If entry->ops->close_p() fails, do not decrement s_open_count
to prevent FD count corruption. Return early with the error code
instead.
This commit is contained in:
Tomáš Rohlínek
2026-06-02 10:37:16 +02:00
parent 42f3ed4d51
commit 68b34d9883
+4 -1
View File
@@ -151,6 +151,9 @@ int console_close(__attribute__((unused)) void *ctx, int fd)
}
int ret = entry->ops->close_p(entry->vfs_ctx, fd);
if (ret != 0) {
return ret;
}
/* Close auxiliaries when last console fd is closed */
_lock_acquire(&s_lock);
@@ -168,7 +171,7 @@ int console_close(__attribute__((unused)) void *ctx, int fd)
}
_lock_release(&s_lock);
return ret;
return 0;
}
ssize_t console_write(__attribute__((unused)) void *ctx, int fd, const void *data, size_t size)