Skip to content

FDC2x1x driver contains critical memory access issues #90790

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

Open
1 task
TylerBird opened this issue May 29, 2025 · 3 comments
Open
1 task

FDC2x1x driver contains critical memory access issues #90790

TylerBird opened this issue May 29, 2025 · 3 comments
Labels
bug The issue is a bug, or the PR is fixing a bug

Comments

@TylerBird
Copy link

TylerBird commented May 29, 2025

Describe the bug

I wanted to use the TI sensor fdc2x1x (onboard I have a FDC2214). The driver is also available. After integration, the controller did not start and I received a “fatal exception” error.

Image

First, I had an ESP32 (board: M5StickC-plus, flashed via UART), then I tried it with an STM32L552 (flashed via STLink V3) controller.

After ruling out the app code as the source of the error, I took a look at the driver. Here I discovered memory access violations.
For example, here:
Note the variable access cfg->ch_cfg->fin_sel which is channel specific and therefore must be implemented as follows: cfg->ch_cfg-[ch].fin_sel.

Image

I have noticed 3 of these access violations.

Furthermore, I use the chip without the sd_gpio.
In the code, however, the function fdc2x1x_init(const struct device *dev) incorrectly checks whether this has been set in the device tree.

Here is what helped me:
if (cfg->sd_gpio.port->name) { -> if (cfg->sd_gpio.port) {

Regression

  • This is a regression.

Steps to reproduce

Execute the example from the folder samples/sensor/fdc2x1x.

Relevant log output

Impact

Annoyance – Minor irritation; no significant impact on usability or functionality.

Environment

  • Linux Ubuntu
  • Zephyr SDK with VSCode
  • zephyrproject-rtos with revision: v4.1.0-rc3

Additional Context

No response

@TylerBird TylerBird added the bug The issue is a bug, or the PR is fixing a bug label May 29, 2025
Copy link

Hi @TylerBird! 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. 🤖💙

@TylerBird
Copy link
Author

TylerBird commented May 29, 2025

The driver appears to be correct.

The original issue I had was that I did not defined the SD pin in the device tree.
Based on the documentation (https://docs.zephyrproject.org/latest/build/dts/api/bindings/sensor/ti%2Cfdc2x1x.html) for sd-gpio, where it does not say “This property is required” I assume that I do not need to specify the pin.

In my case, I set the SD pin in the hardware to “always active” using a pull-down resistor. So the pin is not connected to my controller.

@NotAnsgar
Copy link

NotAnsgar commented May 29, 2025

I checked the sensor readings, and they’re correct when an sd-gpio is provided; the documentation doesn’t list it as mandatory.

When sd-gpio isn’t specified, Zephyr raises an EXCEPTION.

While debugging the initialization I found that sd_gpio is NULL, so dereferencing its name member triggers the exception.

A straightforward fix is to replace
if (cfg->sd_gpio.port->name) {

with

if (cfg->sd_gpio.port) {.

After this change, the FDC2214 can be read both with and without an sd-gpio in the device tree and the fdc2x1x_init_sd_pin(dev) will only be called if the sd-gpio is specified.

I’m not certain whether this will later interfere with power-management routines that use the pin to shut down the FDC, but the adjustment probably best matches the driver author’s intent.

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