Skip to content

Two more issues found by Claude#1189

Open
vojtechtrefny wants to merge 2 commits intostoraged-project:masterfrom
vojtechtrefny:master_claude-fixes
Open

Two more issues found by Claude#1189
vojtechtrefny wants to merge 2 commits intostoraged-project:masterfrom
vojtechtrefny:master_claude-fixes

Conversation

@vojtechtrefny
Copy link
Copy Markdown
Member

@vojtechtrefny vojtechtrefny commented Mar 27, 2026

I think we are close to fixing everything :-)

Summary by CodeRabbit

  • Bug Fixes
    • Fixed stability issue in NVMe connection establishment when host identification is unavailable
    • Improved partition resizing compatibility on systems with older library versions to prevent crashes

vojtechtrefny and others added 2 commits March 27, 2026 15:44
The fdisk_unref_partition() call was commented out due to a double-free
bug in libfdisk (fixed in util-linux 2.35). Add a version-guarded unref
to prevent the leak on fixed versions while preserving the workaround
for older ones.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The g_free(host_id_val) call is unreachable with a non-NULL value
since it's inside a `if (host_id_val == NULL)` block.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

Two cleanup-related bug fixes: removed unconditional memory cleanup call in NVMe fabrics error path; added version-conditional cleanup in partition management to prevent double-free issues on older libfdisk versions.

Changes

Cohort / File(s) Summary
NVMe Fabrics Error Path
src/plugins/nvme/nvme-fabrics.c
Removed g_free(host_id_val) call in error path when host ID cannot be determined in bd_nvme_connect.
Partition Management Version Compatibility
src/plugins/part.c
Added version check to conditionally call fdisk_unref_partition(pa) only when fdisk_version >= 2350 to prevent double-free issues with older libfdisk versions in bd_part_resize_part().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Two more issues found by Claude' is vague and does not clearly describe the specific changes made in the pull request (memory management fixes in nvme-fabrics and partition resizing code). Revise the title to be more specific about the actual changes, such as 'Fix memory management issues in nvme-fabrics and partition resizing' or similar.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/plugins/part.c (1)

1715-1718: Version-guarded unref correctly fixes the leak on libfdisk >= 2.35.

The fix properly restores fdisk_unref_partition() behind a version guard, avoiding the reference leak on libfdisk ≥ 2.35 while preserving the workaround for the double-free bug in older versions. The code change is correct.

However, several error paths in bd_part_resize_part() (lines 1588, 1609, 1640, 1672, 1684, 1697, 1708) call fdisk_unref_partition(pa) unconditionally. Since pa originates from the same fdisk_get_partition() call regardless of success or failure, these error paths should also apply the version guard for consistency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/plugins/part.c` around lines 1715 - 1718, In bd_part_resize_part(),
several error paths unconditionally call fdisk_unref_partition(pa) which
contradicts the version-guarded unref used elsewhere; update each error path
(the calls at the error exits near the checks at lines handling failures after
fdisk_get_partition()) to only call fdisk_unref_partition(pa) when fdisk_version
>= 2350 (or use the same fdisk_version check used in the existing fix), i.e.,
wrap those fdisk_unref_partition(pa) invocations in the same version guard or
replace them with the guarded helper so pa is only unref'd for libfdisk >= 2.35
while preserving the older workaround for earlier versions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/plugins/part.c`:
- Around line 1715-1718: In bd_part_resize_part(), several error paths
unconditionally call fdisk_unref_partition(pa) which contradicts the
version-guarded unref used elsewhere; update each error path (the calls at the
error exits near the checks at lines handling failures after
fdisk_get_partition()) to only call fdisk_unref_partition(pa) when fdisk_version
>= 2350 (or use the same fdisk_version check used in the existing fix), i.e.,
wrap those fdisk_unref_partition(pa) invocations in the same version guard or
replace them with the guarded helper so pa is only unref'd for libfdisk >= 2.35
while preserving the older workaround for earlier versions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1dfd12d9-0721-46c0-bbcb-306468df758e

📥 Commits

Reviewing files that changed from the base of the PR and between 9a82a23 and f9dab68.

📒 Files selected for processing (2)
  • src/plugins/nvme/nvme-fabrics.c
  • src/plugins/part.c
💤 Files with no reviewable changes (1)
  • src/plugins/nvme/nvme-fabrics.c

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.

1 participant