Re: [patch 2/6] ipv6 - make xfrm6_init to return an error code

2007-12-07 Thread David Miller
From: Daniel Lezcano [EMAIL PROTECTED]
Date: Thu, 06 Dec 2007 14:53:31 +0100

 The xfrm initialization function does not return any error code, so
 if there is an error, the caller can not be advise of that.
 This patch checks the return code of the different called functions
 in order to return a successful or failed initialization.
 
 Signed-off-by: Daniel Lezcano [EMAIL PROTECTED]
 Acked-by: Benjamin Thery [EMAIL PROTECTED]

Applied, thanks.
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 2/6] ipv6 - make xfrm6_init to return an error code

2007-12-06 Thread Daniel Lezcano
The xfrm initialization function does not return any error code, so
if there is an error, the caller can not be advise of that.
This patch checks the return code of the different called functions
in order to return a successful or failed initialization.

Signed-off-by: Daniel Lezcano [EMAIL PROTECTED]
Acked-by: Benjamin Thery [EMAIL PROTECTED]
---
 include/net/xfrm.h  |4 ++--
 net/ipv6/xfrm6_policy.c |   22 +-
 net/ipv6/xfrm6_state.c  |4 ++--
 3 files changed, 21 insertions(+), 9 deletions(-)

Index: net-2.6.25/include/net/xfrm.h
===
--- net-2.6.25.orig/include/net/xfrm.h
+++ net-2.6.25/include/net/xfrm.h
@@ -1066,11 +1066,11 @@ struct xfrm6_tunnel {
 
 extern void xfrm_init(void);
 extern void xfrm4_init(void);
-extern void xfrm6_init(void);
+extern int xfrm6_init(void);
 extern void xfrm6_fini(void);
 extern void xfrm_state_init(void);
 extern void xfrm4_state_init(void);
-extern void xfrm6_state_init(void);
+extern int xfrm6_state_init(void);
 extern void xfrm6_state_fini(void);
 
 extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, 
void*), void *);
Index: net-2.6.25/net/ipv6/xfrm6_policy.c
===
--- net-2.6.25.orig/net/ipv6/xfrm6_policy.c
+++ net-2.6.25/net/ipv6/xfrm6_policy.c
@@ -269,9 +269,9 @@ static struct xfrm_policy_afinfo xfrm6_p
.fill_dst = xfrm6_fill_dst,
 };
 
-static void __init xfrm6_policy_init(void)
+static int __init xfrm6_policy_init(void)
 {
-   xfrm_policy_register_afinfo(xfrm6_policy_afinfo);
+   return xfrm_policy_register_afinfo(xfrm6_policy_afinfo);
 }
 
 static void xfrm6_policy_fini(void)
@@ -279,10 +279,22 @@ static void xfrm6_policy_fini(void)
xfrm_policy_unregister_afinfo(xfrm6_policy_afinfo);
 }
 
-void __init xfrm6_init(void)
+int __init xfrm6_init(void)
 {
-   xfrm6_policy_init();
-   xfrm6_state_init();
+   int ret;
+
+   ret = xfrm6_policy_init();
+   if (ret)
+   goto out;
+
+   ret = xfrm6_state_init();
+   if (ret)
+   goto out_policy;
+out:
+   return ret;
+out_policy:
+   xfrm6_policy_fini();
+   goto out;
 }
 
 void xfrm6_fini(void)
Index: net-2.6.25/net/ipv6/xfrm6_state.c
===
--- net-2.6.25.orig/net/ipv6/xfrm6_state.c
+++ net-2.6.25/net/ipv6/xfrm6_state.c
@@ -198,9 +198,9 @@ static struct xfrm_state_afinfo xfrm6_st
.transport_finish   = xfrm6_transport_finish,
 };
 
-void __init xfrm6_state_init(void)
+int __init xfrm6_state_init(void)
 {
-   xfrm_state_register_afinfo(xfrm6_state_afinfo);
+   return xfrm_state_register_afinfo(xfrm6_state_afinfo);
 }
 
 void xfrm6_state_fini(void)

-- 
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html