Patchwork sparc: fix the return value of module_alloc()

login
register
mail settings
Submitter Wei Yongjun
Date Sept. 21, 2012, 4:57 a.m.
Message ID <CAPgLHd-ND_itgeVLvvqFZEU1peMuCk=dAfFhkH68KFV7biHhzA@mail.gmail.com>
Download mbox | patch
Permalink /patch/185572/
State Accepted
Delegated to: David Miller
Headers show

Comments

Wei Yongjun - Sept. 21, 2012, 4:57 a.m.
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

In case of error, function module_alloc() in other platform never
returns ERR_PTR(), and all of the user only check for NULL, so
we'd better return NULL instead of ERR_PTR().

dpatch engine is used to auto generated this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 arch/sparc/kernel/module.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Sept. 21, 2012, 7:16 p.m.
From: Wei Yongjun <weiyj.lk@gmail.com>
Date: Fri, 21 Sep 2012 12:57:51 +0800

> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> In case of error, function module_alloc() in other platform never
> returns ERR_PTR(), and all of the user only check for NULL, so
> we'd better return NULL instead of ERR_PTR().
> 
> dpatch engine is used to auto generated this patch.
> (https://github.com/weiyj/dpatch)
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c
index 15e0a16..df7e16c 100644
--- a/arch/sparc/kernel/module.c
+++ b/arch/sparc/kernel/module.c
@@ -48,9 +48,7 @@  void *module_alloc(unsigned long size)
 		return NULL;
 
 	ret = module_map(size);
-	if (!ret)
-		ret = ERR_PTR(-ENOMEM);
-	else
+	if (ret)
 		memset(ret, 0, size);
 
 	return ret;