From: Olaf Kirch <[EMAIL PROTECTED]>
Date: Fri, 11 Nov 2005 11:03:19 +0100

> The patch below fixes a minor issue with inet6_init.
> I noticed though that the code explicitly ignores
> the error code of sock_register by calling:
>       (void) sock_register(&inet6_family_ops);
> Why does it do this?

Good question.

It should definitely check the return value there.

There is another bug I see there in the cleanup path too.
We don't unregister the inet6 protosw on the failure path.
But this appears totally harmless since you can't reference
the inet6 proto switch table once you unload the ipv6
module.  So I'll leave this alone for now.

So putting your patch and the sock_register() check together
we end up with the following.

diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 4f8795a..c63b8ce 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -699,12 +699,14 @@ static int __init inet6_init(void)
        /* Register the family here so that the init calls below will
         * be able to create sockets. (?? is this dangerous ??)
         */
-       (void) sock_register(&inet6_family_ops);
+       err = sock_register(&inet6_family_ops);
+       if (err)
+               goto out_unregister_raw_proto;
 
        /* Initialise ipv6 mibs */
        err = init_ipv6_mibs();
        if (err)
-               goto out_unregister_raw_proto;
+               goto out_unregister_sock;
        
        /*
         *      ipngwg API draft makes clear that the correct semantics
@@ -796,6 +798,8 @@ icmp_fail:
        ipv6_sysctl_unregister();
 #endif
        cleanup_ipv6_mibs();
+out_unregister_sock:
+       sock_unregister(PF_INET6);
 out_unregister_raw_proto:
        proto_unregister(&rawv6_prot);
 out_unregister_udp_proto:
-
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

Reply via email to