]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ext4: fix potential buffer head leak when add_dirent_to_buf() returns ENOSPC
authorTheodore Ts'o <tytso@mit.edu>
Mon, 23 Nov 2009 12:25:49 +0000 (07:25 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 14 Dec 2009 17:44:47 +0000 (09:44 -0800)
commit6662a8d03104516c53170257b837d8a03e86db39
tree75d4812670404d403d040e45b074272213ba1c58
parentd10a8f05208b66c0b29562a9601601b9a7b5d9ac
ext4: fix potential buffer head leak when add_dirent_to_buf() returns ENOSPC

(cherry picked from commit 2de770a406b06dfc619faabbf5d85c835ed3f2e1)

Previously add_dirent_to_buf() did not free its passed-in buffer head
in the case of ENOSPC, since in some cases the caller still needed it.
However, this led to potential buffer head leaks since not all callers
dealt with this correctly.  Fix this by making simplifying the freeing
convention; now add_dirent_to_buf() *never* frees the passed-in buffer
head, and leaves that to the responsibility of its caller.  This makes
things cleaner and easier to prove that the code is neither leaking
buffer heads or calling brelse() one time too many.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Curt Wohlgemuth <curtw@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/ext4/namei.c