mirror of
https://github.com/apache/nuttx.git
synced 2026-08-18 12:08:16 +00:00
poll: fix covertify issue about out-of-bound access fds
when i is zero and file_get is failed, num is -1, it's uint32_max for nfds. so remove num and simplify code logic. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
11dc1df189
commit
c1b2b1b4fb
1 changed files with 6 additions and 11 deletions
|
|
@ -161,25 +161,20 @@ static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds,
|
|||
if (fds[i].fd >= 0)
|
||||
{
|
||||
FAR struct file *filep;
|
||||
int num = i;
|
||||
|
||||
ret = file_get(fds[i].fd, &filep);
|
||||
if (ret < 0)
|
||||
{
|
||||
num -= 1;
|
||||
}
|
||||
else
|
||||
if (ret >= 0)
|
||||
{
|
||||
ret = file_poll(filep, &fds[i], true);
|
||||
if (ret < 0)
|
||||
{
|
||||
file_put(filep);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
if (num >= 0)
|
||||
{
|
||||
poll_teardown(fds, num, &count);
|
||||
}
|
||||
|
||||
poll_teardown(fds, i, &count);
|
||||
fds[i].revents |= POLLERR;
|
||||
fds[i].arg = NULL;
|
||||
fds[i].cb = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue