Re: [PATCH] af_ipv6.c: check proc_net_create and cleanups

From: Arnaldo Carvalho de Melo (acme@conectiva.com.br)
Date: Mon Sep 11 2000 - 09:56:12 EST


Em Mon, Sep 11, 2000 at 08:35:59PM +0400, kuznet@ms2.inr.ac.ru escreveu:
> Hello!
>
> > we need to set sk->dead to 1 before calling inet_sock_release in
> > inet6_create?
>
> It is a remnant of the past. Delete it here and in af_inet.c,
> when you will send new patch to David.
>
> Alexey

Here it is.

        - Arnaldo

--- linux-2.4.0-test8/net/ipv4/af_inet.c Thu Aug 24 07:40:17 2000
+++ linux-2.4.0-test8.acme/net/ipv4/af_inet.c Mon Sep 11 11:48:37 2000
@@ -390,7 +390,6 @@
         if (sk->prot->init) {
                 int err = sk->prot->init(sk);
                 if (err != 0) {
- sk->dead = 1;
                         inet_sock_release(sk);
                         return(err);
                 }
--- linux-2.4.0-test8/net/ipv6/af_inet6.c Wed Apr 26 16:13:17 2000
+++ linux-2.4.0-test8.acme/net/ipv6/af_inet6.c Mon Sep 11 11:24:58 2000
@@ -11,6 +11,7 @@
  *
  * Fixes:
  * Hideaki YOSHIFUJI : sin6_scope_id support
+ * Arnaldo Melo : check proc_net_create return, cleanups
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -189,7 +190,7 @@
         if (sk->prot->init) {
                 int err = sk->prot->init(sk);
                 if (err != 0) {
- sk->dead = 1;
+ MOD_DEC_USE_COUNT;
                         inet_sock_release(sk);
                         return(err);
                 }
@@ -395,10 +396,8 @@
         {
         case FIOSETOWN:
         case SIOCSPGRP:
- err = get_user(pid, (int *) arg);
- if(err)
- return err;
-
+ if (get_user(pid, (int *) arg))
+ return -EFAULT;
                 /* see sock_no_fcntl */
                 if (current->pid != pid && current->pgrp != -pid &&
                     !capable(CAP_NET_ADMIN))
@@ -407,10 +406,7 @@
                 return(0);
         case FIOGETOWN:
         case SIOCGPGRP:
- err = put_user(sk->proc,(int *)arg);
- if(err)
- return err;
- return(0);
+ return put_user(sk->proc,(int *)arg);
         case SIOCGSTAMP:
                 if(sk->stamp.tv_sec==0)
                         return -ENOENT;
@@ -550,6 +546,20 @@
         err = igmp6_init(&inet6_family_ops);
         if (err)
                 goto igmp_fail;
+ /* Create /proc/foo6 entries. */
+#ifdef CONFIG_PROC_FS
+ err = -ENOMEM;
+ if (!proc_net_create("raw6", 0, raw6_get_info))
+ goto proc_raw6_fail;
+ if (!proc_net_create("tcp6", 0, tcp6_get_info))
+ goto proc_tcp6_fail;
+ if (!proc_net_create("udp6", 0, udp6_get_info))
+ goto proc_udp6_fail;
+ if (!proc_net_create("sockstat6", 0, afinet6_get_info))
+ goto proc_sockstat6_fail;
+ if (!proc_net_create("snmp6", 0, afinet6_get_snmp))
+ goto proc_snmp6_fail;
+#endif
         ipv6_netdev_notif_init();
         ipv6_packet_init();
         ip6_route_init();
@@ -561,15 +571,6 @@
         udpv6_init();
         tcpv6_init();
 
- /* Create /proc/foo6 entries. */
-#ifdef CONFIG_PROC_FS
- proc_net_create("raw6", 0, raw6_get_info);
- proc_net_create("tcp6", 0, tcp6_get_info);
- proc_net_create("udp6", 0, udp6_get_info);
- proc_net_create("sockstat6", 0, afinet6_get_info);
- proc_net_create("snmp6", 0, afinet6_get_snmp);
-#endif
-
         /* Now the userspace is allowed to create INET6 sockets. */
         (void) sock_register(&inet6_family_ops);
         
@@ -579,6 +580,18 @@
         return;
 #endif
 
+#ifdef CONFIG_PROC_FS
+proc_snmp6_fail:
+ proc_net_remove("sockstat6");
+proc_sockstat6_fail:
+ proc_net_remove("udp6");
+proc_udp6_fail:
+ proc_net_remove("tcp6");
+proc_tcp6_fail:
+ proc_net_remove("raw6");
+proc_raw6_fail:
+ igmp6_cleanup();
+#endif
 igmp_fail:
         ndisc_cleanup();
 ndisc_fail:
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Sep 15 2000 - 21:00:15 EST