Opened 11 years ago

Closed 11 years ago

#9909 closed bug (fixed)

[kernel/fs] vfs.cpp: Memory leak

Reported by: mt Owned by: axeld
Priority: normal Milestone: R1
Component: System/Kernel Version: R1/Development
Keywords: kernel/fs Cc:
Blocked By: Blocking:
Platform: All

Description

In get_file_system(), if strncmp() returns non-zero, then memory pointed by fsName is leaked, which causes memory leak in fs_mount().

Attachments (2)

0020-Fix-memory-leak.patch (951 bytes ) - added by mt 11 years ago.
Patch
report-e9209f.html (1.2 MB ) - added by mt 11 years ago.
Report by Clang Static Analyzer

Download all attachments as: .zip

Change History (4)

by mt, 11 years ago

Attachment: 0020-Fix-memory-leak.patch added

Patch

comment:1 by mt, 11 years ago

patch: 01

by mt, 11 years ago

Attachment: report-e9209f.html added

Report by Clang Static Analyzer

comment:2 by bonefish, 11 years ago

Resolution: fixed
Status: newclosed

Your patch doesn't fix the issue. get_file_system() doesn't free or take ownership of the specified name in either case, nor is it supposed to do so. The leak is in the loop in fs_mount() -- the name simply needs to be freed after the iteration. The free() was just missing in the success case. Fixed in hrev45939. Instead of adding another free(), I removed the existing ones and used a MemoryDeleter, though.

At any rate, thanks for the analysis!

Note: See TracTickets for help on using tickets.