Skip to contentSkip to conversation

AS apple talk protocol register_snap_client failed

PATCH In review guanxun mu 2 participants 2 messages Dec 14, 2007 Networking

lore
Share & tools
lore

guanxun mu

author
#0 lore raw

PATCH 1/1 AS apple talk protocol register_snap_client failed

[PACTH APPLETALK]

This patch update proto_init process when register_snap_client failed

net/appletalk/aarp.c +4 -1
index 6c5c6dc..d6573f6 100644
@@ -873,7 +873,10 @@ void __init aarp_proto_init(void)
 {
        aarp_dl = register_snap_client(aarp_snap_id, aarp_rcv);
        if (!aarp_dl)
-               printk(KERN_CRIT "Unable to register AARP with SNAP.\n");
+       {
+               printk(KERN_CRIT "Unable to register AARP with SNAP.\n");
+               return;
+       }
        init_timer(&aarp_timer);
        aarp_timer.function = aarp_expire_timeout;
        aarp_timer.data     = 0;
net/appletalk/ddp.c +9 -3
index e0d37d6..ce9929c 100644
@@ -1894,9 +1894,9 @@ static int __init atalk_init(void)
 
        (void)sock_register(&atalk_family_ops);
        ddp_dl = register_snap_client(ddp_snap_id, atalk_rcv);
-       if (!ddp_dl)
-               printk(atalk_err_snap);
-
+       if (!ddp_dl)
+               goto failed;
+
        dev_add_pack(&ltalk_packet_type);
        dev_add_pack(&ppptalk_packet_type);
 
@@ -1906,7 +1906,13 @@ static int __init atalk_init(void)
        atalk_register_sysctl();
 out:
        return rc;
+failed:
+       printk(atalk_err_snap);
+       sock_unregister(PF_APPLETALK);
+       proto_unregister(&ddp_proto);
+       return -1;
 }
+
 module_init(atalk_init);
 
 /*
maintainer
#1 lore raw

From: "guanxun mu" <[email protected]>
Date: Fri, 14 Dec 2007 14:03:05 +0800

Quoted 12 lines

[PACTH APPLETALK]

This patch update proto_init process when register_snap_client failed

net/appletalk/aarp.c +0 -0
index 6c5c6dc..d6573f6 100644
@@ -873,7 +873,10 @@ void __init aarp_proto_init(void)
 {

net/appletalk/aarp.c void __init aarp_proto_init(void) · line 882

Quoted 10 lines
net/appletalk/aarp.c +4 -1
        aarp_dl = register_snap_client(aarp_snap_id, aarp_rcv);
        if (!aarp_dl)
-               printk(KERN_CRIT "Unable to register AARP with SNAP.\n");
+       {
+               printk(KERN_CRIT "Unable to register AARP with SNAP.\n");
+               return;
+       }
        init_timer(&aarp_timer);
        aarp_timer.function = aarp_expire_timeout;
        aarp_timer.data     = 0;

Wrong coding style, the openning brace should be on the same line
as the if() check, see Documentation/CodingStyle Your email
client has also corrupted the tab characters into spaces, making the patch unusable even if it were correct.

Next, if you are going to do this, you should modify aarp_proto_init() to return error values, so that atalk_init() can see it and thus undo the initialization it does and return an error for the module load.

It is not useful to add error checks, without propagating them, because an OOPS is just as good as a partially-initialized protocol since that is likely to crash or malfunction as well.

The protocol is thus equally broken before and after your changes.

Please completely implement this fix, thank you.