lkml.org 
[lkml]   [2005]   [Oct]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [TRIVIAL] Error checks omitted in init_tmpfs() in mm/tiny-shmem.c
Matt Mackall wrote:
> On Mon, Oct 24, 2005 at 12:29:45AM -0500, Hareesh Nagarajan wrote:
>> The existing code in init_tmpfs() in mm/tiny-shmem.c does not handle the
>> cases when the calls to register_filesystem() and kern_mount() fail.
>> This patch adds those checks.
>
> Hmm. Did you actually encounter this?

No, I haven't. I was just reading the source code when I chanced upon
these trivial error checking omissions.

> I'd rather use BUG_ON. Passing up errors is only useful when the code
> above can and will do something useful with the information.

[ Snip ]

> And what could the higher level, which is simply looping through init
> functions, do to handle the error? Retry? Print a warning? Better to
> stop everything outright when we encounter a problem we expect should
> never happen so it doesn't go by undiagnosed.

Makes sense. New patch attached.

Signed-off-by: Hareesh Nagarajan <hnagar2@gmail.com>
--- linux-2.6.13.4/mm/tiny-shmem.c 2005-10-10 13:54:29.000000000 -0500
+++ linux-2.6.13.4-edit/mm/tiny-shmem.c 2005-10-24 03:43:38.614071000 -0500
@@ -31,12 +31,18 @@

static int __init init_tmpfs(void)
{
- register_filesystem(&tmpfs_fs_type);
+ int error;
+
+ error = register_filesystem(&tmpfs_fs_type);
+ BUG_ON(error);
+
#ifdef CONFIG_TMPFS
devfs_mk_dir("shm");
#endif
shm_mnt = kern_mount(&tmpfs_fs_type);
- return 0;
+ BUG_ON(IS_ERR(shm_mnt));
+
+ return error;
}
module_init(init_tmpfs)
\
 
 \ /
  Last update: 2005-10-24 10:59    [W:0.104 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site