Skip to content

drivers: adc_ad4130: Fix out-of-bounds accesses to channel_setup_cfg #90575

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

Merged

Conversation

anangl
Copy link
Member

@anangl anangl commented May 26, 2025

Correct the size of the channel_setup_cfg array, as it should contain entries for all available channels (AD4130_MAX_CHANNELS), not for the available configuration slots (AD4130_MAX_SETUPS).
Move also checking of the channel index to the very beginning of adc_ad4130_channel_setup(), to avoid potential writes to .live_cfg beyond the channel_setup_cfg array.

Fixes #90507.
Fixes #90514.

@anangl anangl added the bug The issue is a bug, or the PR is fixing a bug label May 26, 2025
@github-actions github-actions bot added area: ADC Analog-to-Digital Converter (ADC) platform: ADI Analog Devices, Inc. size: XS A PR changing only a single line of code labels May 26, 2025
@anangl
Copy link
Member Author

anangl commented May 26, 2025

cc @oknshn

Correct the size of the channel_setup_cfg array, as it should contain
entries for all available channels (AD4130_MAX_CHANNELS), not for the
available configuration slots (AD4130_MAX_SETUPS).
Move also checking of the channel index to the very beginning of
adc_ad4130_channel_setup(), to avoid potential writes to .live_cfg
beyond the channel_setup_cfg array.

Signed-off-by: Andrzej Głąbek <[email protected]>
@anangl anangl force-pushed the fix_out_of_bounds_reads_ad4130 branch from b3ab146 to f3a1717 Compare May 26, 2025 08:21
@anangl anangl changed the title drivers: adc_ad4130: Fix loop in adc_ad4130_find_similar_configuration() drivers: adc_ad4130: Fix out-of-bounds accesses to channel_setup_cfg May 26, 2025
@kartben kartben merged commit ec8632d into zephyrproject-rtos:main May 28, 2025
29 of 31 checks passed
@anangl anangl deleted the fix_out_of_bounds_reads_ad4130 branch May 28, 2025 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ADC Analog-to-Digital Converter (ADC) bug The issue is a bug, or the PR is fixing a bug platform: ADI Analog Devices, Inc. size: XS A PR changing only a single line of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Coverity CID: 520273] Out-of-bounds read in drivers/adc/adc_ad4130.c [Coverity CID: 520282] Out-of-bounds read in drivers/adc/adc_ad4130.c
4 participants