public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* Proper error handling on NULL pointers
@ 2009-10-19 10:36 Andi Drebes
  2009-10-21 17:43 ` Diego Calleja
  0 siblings, 1 reply; 11+ messages in thread
From: Andi Drebes @ 2009-10-19 10:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Diego Calleja, Andi Kleen

Hi!
I recently posted a message that addresses the usage of BUG_ON for memory shortages concerning btrfs_alloc_path() (see [1]):

	...
	path = btrfs_alloc_path();
	BUG_ON(!path);
	ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
	...

It seems that this is not the only place where NULL pointers returned by allocation functions are not handled properly. For instance in start_transaction(), errors are not handled at all:

	struct btrfs_trans_handle *h =
		kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS);
	...
	/* Access h without check */
	...
	return h;

Repairing this would sometimes require to review a bunch of functions that directly or indirectly refer to it. As pointed out by Andi Kleen two weeks ago in a reply to message by Diego Calleja (see [2] and [3]), this might not be trivial, because these errors are sometimes not handled at all in highlevel functions.

However, is there any interest in patches fixing these problems? If yes: what would be the best strategy? Should we start fixing this "layer by layer" -- the low-level functions first and the high-level functions later on? Or should use come kind of "vertical approach" -- one low-level function and all of its callers at once?

If these issues currently don't have a very high priority, we could collect them in a TODO section in the Wiki or something. Any suggestions?

	Cheers,
		Andi

[1] http://www.spinics.net/lists/linux-btrfs/msg03221.html
[2] http://www.spinics.net/lists/linux-btrfs/msg03197.html
[3] http://www.spinics.net/lists/linux-btrfs/msg03198.html

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

end of thread, other threads:[~2009-10-30 13:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-19 10:36 Proper error handling on NULL pointers Andi Drebes
2009-10-21 17:43 ` Diego Calleja
2009-10-22 10:15   ` Andi Drebes
2009-10-22 14:10     ` Diego Calleja
2009-10-22 16:23       ` Andi Drebes
2009-10-23 18:08     ` Jeff Mahoney
2009-10-26  9:14       ` Chris Mason
2009-10-26 14:24         ` Jeff Mahoney
2009-10-30 13:27         ` Jeff Mahoney
2009-10-30 13:49           ` Chris Mason
2009-10-26  9:23   ` Chris Mason

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