Skip to content

Fix: Avoid double free on ltfsck and mkltfs#593

Merged
rangelmx merged 1 commit into
LinearTapeFileSystem:release/v2.4.8.4from
XV02:fix/double-free
Jun 2, 2026
Merged

Fix: Avoid double free on ltfsck and mkltfs#593
rangelmx merged 1 commit into
LinearTapeFileSystem:release/v2.4.8.4from
XV02:fix/double-free

Conversation

@XV02
Copy link
Copy Markdown
Contributor

@XV02 XV02 commented May 29, 2026

Summary of changes

This PR fixes a free that was left from a section that was refactored with a cleanup

Description

When adding memory checks the files ltfsck.c and mkltfs.c were reworked to use a cleanup section, but in doing so an old free was left in there making a double free happen

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have confirmed my fix is effective or that my feature works

@XV02 XV02 requested review from amissael95, madjesc and vandelvan May 29, 2026 17:18
@XV02 XV02 self-assigned this May 29, 2026
@XV02 XV02 changed the title fix: Avoid double free on ltfsck and mkltfs Fix: Avoid double free on ltfsck and mkltfs May 29, 2026
@vandelvan
Copy link
Copy Markdown
Member

Hi @XV02
Could you share the output of the ltfsck now with the fix please, thanks for working on this!

@madjesc
Copy link
Copy Markdown

madjesc commented Jun 1, 2026

LGTM 🔥

@XV02
Copy link
Copy Markdown
Contributor Author

XV02 commented Jun 1, 2026

Test

Running the same command where the issue was identified, the problem no longer happens.

# ltfsck -l /dev/sg16
LTFS16000I Starting ltfsck, LTFS version 2.4.8.4 (Prelim), log level 2.
LTFS16088I Launched by "ltfsck -l /dev/sg16".
LTFS16089I This binary is built for Linux (x86_64).
LTFS16090I GCC version is 8.5.0 20210514 (Red Hat 8.5.0-28).
LTFS17087I Kernel version: Linux version 4.18.0-553.124.1.el8_10.x86_64 (mockbuild@x86-64-04.build.eng.rdu2.redhat.com) (gcc version 8.5.0 20210514 (Red Hat 8.5.0-28) (GCC)) #1 SMP Mon May 11 07:30:18 EDT 2026 i386.
LTFS17089I Distribution: NAME="Red Hat Enterprise Linux".
LTFS17089I Distribution: Red Hat Enterprise Linux release 8.10 (Ootpa).
LTFS17089I Distribution: Red Hat Enterprise Linux release 8.10 (Ootpa).
LTFS16084I List indexes in backward direction strategy.
LTFS17085I Plugin: Loading "sg" tape backend.
LTFS30209I Opening a device through sg-ibmtape driver (/dev/sg16).
LTFS30250I Opened the SCSI tape device 13.0.7.0 (/dev/sg16).
LTFS30207I Vendor ID is IBM     .
LTFS30208I Product ID is ULT3580-TD8     .
LTFS30214I Firmware revision is N4Q0.
LTFS30215I Drive serial is 00078DEFB9.
LTFS30285I The reserved buffer size of /dev/sg16 is 1048576.
LTFS30294I Setting up timeout values from RSOC.
LTFS30205I TEST_UNIT_READY (0x00) returns -20209.
LTFS17160I Maximum device block size is 1048576.
LTFS11330I Loading cartridge.
LTFS30205I LOAD_UNLOAD (0x1b) returns -20209.
LTFS30263I LOAD_UNLOAD returns Medium Not Present (-20209) /dev/sg16.
LTFS30262I Forcing drive dump.
LTFS30253I Saving drive dump to /tmp/ltfs_00078DEFB9_2026_0601_141033_f.dmp.
LTFS30205I READPOS (0x34) returns -20209.
LTFS30263I READPOS returns Medium Not Present (-20209) /dev/sg16.
LTFS30262I Forcing drive dump.
LTFS30253I Saving drive dump to /tmp/ltfs_00078DEFB9_2026_0601_141043_f.dmp.
LTFS12016E No medium present.
LTFS11331E Failed to load the cartridge (ltfs_load_tape).
LTFS30205I TEST_UNIT_READY (0x00) returns -20209.
LTFS30205I TEST_UNIT_READY (0x00) returns -20209.
LTFS30205I TEST_UNIT_READY (0x00) returns -20209.
LTFS30205I TEST_UNIT_READY (0x00) returns -20209.
LTFS17188I Device is not ready (-20209).
LTFS16092E Cannot set up tape drive (/dev/sg16).
LTFS30205I TEST_UNIT_READY (0x00) returns -20209.
LTFS30205I TEST_UNIT_READY (0x00) returns -20209.
LTFS30205I TEST_UNIT_READY (0x00) returns -20209.
LTFS30252I Logical block protection is disabled.

Copy link
Copy Markdown
Member

@vandelvan vandelvan left a comment

Choose a reason for hiding this comment

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

LGTM Thanks for your contribution

@rangelmx rangelmx merged commit a658c65 into LinearTapeFileSystem:release/v2.4.8.4 Jun 2, 2026
7 checks passed
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.

4 participants