public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix possible pointer dereference
@ 2009-10-06 20:15 Diego Calleja
  2009-10-07  0:03 ` Andi Kleen
  0 siblings, 1 reply; 2+ messages in thread
From: Diego Calleja @ 2009-10-06 20:15 UTC (permalink / raw)
  To: linux-btrfs

We should always check btrfs_alloc_path(). Some places BUG(),
others return -ENOMEM, btrfs_insert_dir_item() seems like it can return
safely.

Signed-off-by: Diego Calleja <diegocg@gmail.com>

--- linux/fs/btrfs/dir-item.c.BAK	2009-10-06 19:00:48.887361896 +0200
+++ linux/fs/btrfs/dir-item.c	2009-10-06 19:01:00.329132291 +0200
@@ -147,6 +147,9 @@ int btrfs_insert_dir_item(struct btrfs_t
 	key.offset = btrfs_name_hash(name, name_len);
 
 	path = btrfs_alloc_path();
+	if (!path)
+		return -ENOMEM;
+
 	path->leave_spinning = 1;
 
 	data_size = sizeof(*dir_item) + name_len;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix possible pointer dereference
  2009-10-06 20:15 [PATCH] Fix possible pointer dereference Diego Calleja
@ 2009-10-07  0:03 ` Andi Kleen
  0 siblings, 0 replies; 2+ messages in thread
From: Andi Kleen @ 2009-10-07  0:03 UTC (permalink / raw)
  To: Diego Calleja; +Cc: linux-btrfs

Diego Calleja <diegocg@gmail.com> writes:

> We should always check btrfs_alloc_path(). Some places BUG(),
> others return -ENOMEM, btrfs_insert_dir_item() seems like it can return
> safely.

The problem is that all the callers don't handle errors.
It doesn't make sense to fix it low-level currently when it cannot be handled
properly higher up anyways.

Proper out of memory handling needs much more work, one liners
don't really help.

-Andi
-- 
ak@linux.intel.com -- Speaking for myself only.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-07  0:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-06 20:15 [PATCH] Fix possible pointer dereference Diego Calleja
2009-10-07  0:03 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox