[patch 01/11] fs: Make unload_nls() NULL pointer safe

From: Thomas Gleixner
Date: Fri Aug 14 2009 - 08:42:59 EST


Most callsites of unload_nls() do
if (nls)
unload_nls(nls);

Check the pointer inside unload_nls() like we do in kfree() so we can
simplify the call sites.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
fs/nls/nls_base.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6-tip/fs/nls/nls_base.c
===================================================================
--- linux-2.6-tip.orig/fs/nls/nls_base.c
+++ linux-2.6-tip/fs/nls/nls_base.c
@@ -270,7 +270,8 @@ struct nls_table *load_nls(char *charset

void unload_nls(struct nls_table *nls)
{
- module_put(nls->owner);
+ if (nls)
+ module_put(nls->owner);
}

static const wchar_t charset2uni[256] = {


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/