public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Will Dyson <will_dyson@pobox.com>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [BKPATCH] [BEFS] fix resource leak on register_filesystem failure
Date: Wed, 24 Sep 2003 14:51:28 -0400	[thread overview]
Message-ID: <1064429488.9009.20.camel@thalience> (raw)

Marco Cova noticed a bug in befs's init code. He said:

> 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 through befs_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
# --------------------------------------------
#
diff -Nru a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
--- a/fs/befs/linuxvfs.c	Mon Sep 22 23:11:17 2003
+++ b/fs/befs/linuxvfs.c	Mon Sep 22 23:11:17 2003
@@ -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


-- 
Will Dyson
"Back off man, I'm a scientist!" -Dr. Peter Venkman


                 reply	other threads:[~2003-09-24 18:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1064429488.9009.20.camel@thalience \
    --to=will_dyson@pobox.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox