Repository navigation
drivers/input/st7123: Clamp reported max_touches to ST7123_MAX_TOUCH_AREAS - #21315
Merged
xiaoxiang781216 merged 1 commit intoOct 31, 2026
Merged
Conversation
…AREAS The driver comment at lines 78-81 states: "The value read back from ST7123_TOUCH_MAX_TOUCHES is clamped to this limit so that a bogus register value can never overrun the frame or sample buffers." However, st7123_register() only checked that max_touches was non-zero and assigned lower.maxpoint directly without enforcing the upper bound against ST7123_MAX_TOUCH_AREAS (10). Because dev->frame.areas, lastx, lasty, and sample_buf are sized to ST7123_MAX_TOUCH_AREAS, an oversized reported touch count would cause an out-of-bounds heap write during the sequential I2C frame read in st7123_data_worker(). Implement the promised clamp in st7123_register() and fix right brace alignment in st7123_probe_device(). Fixes apache#21245. Signed-off-by: Swatantra Yadav <[email protected]> Assisted-by: Google Gemini
|
xiaoxiang781216
approved these changes
Oct 31, 2026
acassis
approved these changes
Oct 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #21245
In
drivers/input/st7123.c, the device capability block read over I2C reportsmax_touches, which was used directly to setlower.maxpoint. On each touch interrupt,st7123_data_worker()computesframelen = ST7123_FRAME_HEADER_SIZE + lower->maxpoint * ST7123_TOUCH_AREA_SIZEand executes a sequential I2C burst read intodev->frame.While the header comment at lines 78–81 states:
st7123_register()only checked thatmax_touches != 0and omitted the upper bound check. Sincedev->frame.areas,lastx,lasty, andsample_bufare all sized toST7123_MAX_TOUCH_AREAS(10), an oversized reported touch count would trigger an out-of-bounds heap write intodevand adjacent heap during the I2C frame read.This patch:
st7123_register()to ensurepriv->device_caps.max_touches <= ST7123_MAX_TOUCH_AREAS.st7123_probe_device()for fullnxstylecompliance across the file.Impact
Testing
tools/nxstyle(0 errors, 0 warnings).struct st7123_frame_t,lastx,lasty,sample_buf).