Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/tcp: Fix clear condition in ofoseg input #9041

Merged
merged 2 commits into from Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions mm/iob/iob_pack.c
Expand Up @@ -51,15 +51,11 @@ FAR struct iob_s *iob_pack(FAR struct iob_s *iob)
unsigned int ncopy;
unsigned int navail;

/* Handle special cases */
/* Handle special cases, preserve at least one iob. */

while (iob->io_len <= 0)
while (iob->io_len <= 0 && iob->io_flink != NULL)
{
iob = iob_free(iob);
if (iob == NULL)
{
return NULL;
}
}

/* Now remember the head of the chain (for the return value) */
Expand Down
3 changes: 2 additions & 1 deletion net/tcp/tcp_input.c
Expand Up @@ -454,10 +454,11 @@ static void tcp_input_ofosegs(FAR struct net_driver_s *dev,
/* Trim l3/l4 header to reserve appdata */

dev->d_iob = iob_trimhead(dev->d_iob, len);
if (dev->d_iob == NULL)
if (dev->d_iob == NULL || dev->d_iob->io_pktlen == 0)
{
/* No available data, clear device buffer */

iob_free_chain(dev->d_iob);
goto clear;
}

Expand Down