From: Andi Kleen <andi@firstfloor.org>
To: Steven Liu <lingjiujianke@gmail.com>
Cc: chris.mason@oracle.com, linux-btrfs@vger.kernel.org,
linux-kernel@vger.kernel.org, liuqi@thunderst.com
Subject: Re: [PATCH] btrfs: check alloc return value before use handle and struct
Date: Wed, 19 May 2010 22:00:20 +0200 [thread overview]
Message-ID: <87r5l7wtkb.fsf@basil.nowhere.org> (raw)
In-Reply-To: <AANLkTimupBIpsY_YtwIw75-ZdilsiFabaaTSs-AJv0Ad@mail.gmail.com> (Steven Liu's message of "Wed\, 19 May 2010 17\:38\:45 +0800")
Steven Liu <lingjiujianke@gmail.com> writes:
> diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
> index e9103b3..230a131 100644
> --- a/fs/btrfs/dir-item.c
> +++ b/fs/btrfs/dir-item.c
> @@ -142,6 +142,8 @@ int btrfs_insert_dir_item(struct
> btrfs_trans_handle *trans, struct btrfs_root
> key.offset = btrfs_name_hash(name, name_len);
>
> path = btrfs_alloc_path();
> + if (!path)
> + return -ENOMEM;
The big problem is handling state unwind in all the callers, not adding
it to the low level code. I attempted it some time ago but it's hard.
Just spewing BUG_ON() all over on memory allocation failure is not
helpful imho, that's not better than simply having clean NULL pointer
faults.
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
prev parent reply other threads:[~2010-05-19 20:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-19 9:38 Steven Liu
2010-05-19 20:00 ` Andi Kleen [this message]
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=87r5l7wtkb.fsf@basil.nowhere.org \
--to=andi@firstfloor.org \
--cc=chris.mason@oracle.com \
--cc=lingjiujianke@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuqi@thunderst.com \
/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
Powered by JetHome