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

Integer overflow in DW I2C driver i2c_dw_data_ask() function. #67692

Closed
RICCIARDI-Adrien opened this issue Jan 16, 2024 · 1 comment
Closed
Labels
bug The issue is a bug, or the PR is fixing a bug

Comments

@RICCIARDI-Adrien
Copy link
Contributor

Describe the bug
The DW I2C controller can implement a reception FIFO as deep as 256 bytes.
However, the computation made by the driver code to determine how many bytes can be asked is stored in a signed 8-bit variable called rx_empty.

If the reception FIFO depth is greater or equal to 128 bytes and the FIFO is currently empty, the rx_empty value will be 128 (or more), which stands for a negative value as the variable is signed.

Thus, the later code checking if the FIFO is full will run while it should not and exit from the i2c_dw_data_ask() function too early.

This hangs the controller in an infinite loop of interrupt storm because the interrupt flags are never cleared.

To Reproduce
Steps to reproduce the behavior:

Expected behavior
The I2C controller should correctly receive the data.

Impact
This is a showstopper because it triggers an i2C interrupt storm because I2C interrupts are never handled.

Logs and console output
None available.

Environment (please complete the following information):

  • OS: Linux
  • Toolchain: Zephyr SDK
  • Commit SHA or Version used: v3.5.0 (commit a6eef0b)

Additional context
This bug has already been fixed on mainline (see #66685).
I was asked by the Zephyr maintainers to file a bug for this issue.

Copy link

Hi @RICCIARDI-Adrien! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

No branches or pull requests

2 participants