Skip to content

Conversation

@staticpayload
Copy link
Owner

@staticpayload staticpayload commented Jan 24, 2026

Summary

  • fix relative-address subtraction to avoid implementation-defined unsigned wrap
  • keep behavior identical for in-range offsets

Testing

  • AWS EC2 (eu-central-2), Amazon Linux 2023 via SSM
  • make defconfig
  • scripts/config --enable FSI --enable FSI_MASTER_AST_CF
  • make W=1 drivers/fsi/fsi-master-ast-cf.o

Log: /Users/staticpayload/kernel-upstream/agent_notes/aws-build-fsi-ast-cf.json

Summary by CodeRabbit

  • Bug Fixes
    • Corrected unaligned read and write length calculations in FSI operations to ensure proper alignment and boundary handling.
    • Fixed relative address calculation to properly support signed address ranges and improve validation.

✏️ Tip: You can customize this high-level summary in your review settings.

cfam_{read,write} split requests into up to 4-byte aligned chunks.
The per-iteration length is computed from the full count and the
current alignment. Once total_len advances, this can exceed the
remaining bytes, leading to copy_{to,from}_user() touching bytes past
the user buffer and advancing the file offset too far.

Clamp each chunk to the minimum of the alignment-based length and the
remaining bytes so each iteration handles only the bytes left.

Fixes: d1dcd67 ("fsi: Add cfam char devices")
Signed-off-by: Chaitanya Mishra <chaitanyamishra.ai@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Jan 24, 2026

📝 Walkthrough

Walkthrough

Two FSI driver files received bug fix updates: fsi-core.c modified per-iteration read/write length calculations to properly account for unaligned offsets and remaining byte counts, while fsi-master-ast-cf.c changed address calculation to use signed arithmetic for correct negative offset validation.

Changes

Cohort / File(s) Summary
FSI Core Length Calculation Fix
drivers/fsi/fsi-core.c
Updated cfam_read and cfam_write per-iteration length calculations from min(count, 4) - (off & 0x3) to min(4 - (off & 0x3), count - total_len) to correctly bound chunk sizes by both alignment remainder and remaining byte count.
FSI Master Address Calculation Fix
drivers/fsi/fsi-master-ast-cf.c
Changed rel_addr calculation to cast operands to int32_t before subtraction, enabling signed arithmetic for proper validation against the -256..255 range.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A leap of logic, bounds now tight,
Signed offsets hop just right,
Min and max in perfect dance,
Alignment fixes at a glance! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fsi: master-ast-cf: fix relative address arithmetic' directly matches the main change in the PR, which fixes signed arithmetic for relative address calculations in the fsi-master-ast-cf driver.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants