Commit 429ad65
committed
drivers: adc: mcux_adc16: Fix buffer size validation for multi-channel sequences
The mcux_adc16 driver's read function fails to correctly validate the user-provided
buffer size when `adc_sequence.options` are used (i.e., for extra samplings
or continuous conversions).
The validation calculation erroneously considered only the size required for a
single channel multiplied by the total number of samplings:
`sizeof(uint16_t) * (extra_samplings + 1)`.
This neglects the total number of channels enabled in `adc_sequence.channels`,
leading to a **buffer overflow** if the sequence includes multiple channels.
Fix this by using `POPCOUNT(sequence->channels)` to determine the correct number
of channels and ensuring the buffer size is sufficient for all requested samples.
Signed-off-by: Badr Bacem KAABIA <[email protected]>1 parent 3af17bf commit 429ad65
1 file changed
+20
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
| 196 | + | |
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
| |||
247 | 249 | | |
248 | 250 | | |
249 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
250 | 265 | | |
251 | | - | |
252 | | - | |
253 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
254 | 271 | | |
255 | 272 | | |
256 | 273 | | |
| |||
0 commit comments