[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87r5l7wtkb.fsf@basil.nowhere.org>
Date: Wed, 19 May 2010 22:00:20 +0200
From: Andi Kleen <andi@...stfloor.org>
To: Steven Liu <lingjiujianke@...il.com>
Cc: chris.mason@...cle.com, linux-btrfs@...r.kernel.org,
linux-kernel@...r.kernel.org, liuqi@...nderst.com
Subject: Re: [PATCH] btrfs: check alloc return value before use handle and struct
Steven Liu <lingjiujianke@...il.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@...ux.intel.com -- Speaking for myself only.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists