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

Munmap Issue with dam-proxy-test.c #7

Open
samprager opened this issue Jun 30, 2023 · 0 comments
Open

Munmap Issue with dam-proxy-test.c #7

samprager opened this issue Jun 30, 2023 · 0 comments

Comments

@samprager
Copy link

samprager commented Jun 30, 2023

It seems like the following code (dma-proxy-test.c) may be incorrect and appears to lead to issues that eventually result in a kernel panic if the test is run multiple times.

Line 422

for (i = 0; i < TX_CHANNEL_COUNT; i++) {
        pthread_join(tx_channels[i].tid, NULL);
        munmap(tx_channels[i].buf_ptr, sizeof(struct channel_buffer));
        close(tx_channels[i].fd);
}
for (i = 0; i < RX_CHANNEL_COUNT; i++) {
      munmap(rx_channels[i].buf_ptr, sizeof(struct channel_buffer));
      close(rx_channels[i].fd);
}

I believe the code should be:

for (i = 0; i < TX_CHANNEL_COUNT; i++) {
        pthread_join(tx_channels[i].tid, NULL);
        munmap(tx_channels[i].buf_ptr, sizeof(struct channel_buffer)* TX_BUFFER_COUNT);
        close(tx_channels[i].fd);
}
for (i = 0; i < RX_CHANNEL_COUNT; i++) {
      munmap(rx_channels[i].buf_ptr, sizeof(struct channel_buffer)* RX_BUFFER_COUNT);
      close(rx_channels[i].fd);
}

Additionally, line 352:

test_size = atoi(argv[2]);
if (test_size > BUFFER_SIZE)
    test_size = BUFFER_SIZE;
test_size *= 1024;

Has a clear bug since BUFFER_SIZE is in Bytes. Code should be

test_size = atoi(argv[2]);
test_size *= 1024;
if (test_size > BUFFER_SIZE)
    test_size = BUFFER_SIZE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant