fix resource leak on register_filesystem failure
Subsystems (2)
Quoted 3 lines · Marco Cova noticed a bug in befs's init code. He
It seems there's a (very) rare-case bug in linuxvfs.c:init_befs_fs In the current implementation, if
register_filesystem()fails, the memory allocated throughbefs_init_inodecache()is not deallocated.
He also provided the trivial patch below (modulo my renaming of the goto labels).
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1228 -> 1.1230
# fs/befs/linuxvfs.c 1.8 -> 1.10
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/09/22 will@thalience.(none) 1.1229
# Fix slab memory leak when register_filesystem fails.
# Caught by Marco Cova
# --------------------------------------------
# 03/09/22 will@thalience.(none) 1.1230
# Fixup for previous cset
# --------------------------------------------
#
fs/befs/linuxvfs.c +12 -2
@@ -939,9 +941,19 @@ err =befs_init_inodecache ();if (err) -return err; + goto unaquire_none; + + err =register_filesystem (&befs_fs_type); +if (err) + goto unaquire_inodecache; + +return 0 ; + +unaquire_inodecache: +befs_destroy_inodecache (); -return register_filesystem (&befs_fs_type); +unaquire_none: +return err; }static void __exit
Signature · 2 lines
Will Dyson "Back off man, I'm a scientist!" -Dr. Peter Venkman