make sure iface->proto_handler is always initialized
authorFelix Fietkau <nbd@openwrt.org>
Tue, 24 Jan 2012 21:39:11 +0000 (22:39 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 24 Jan 2012 21:39:11 +0000 (22:39 +0100)
proto.c

diff --git a/proto.c b/proto.c
index c51637f..1a260cc 100644 (file)
--- a/proto.c
+++ b/proto.c
@@ -176,17 +176,14 @@ proto_init_interface(struct interface *iface, struct blob_attr *attr)
 void
 proto_attach_interface(struct interface *iface, const char *proto_name)
 {
 void
 proto_attach_interface(struct interface *iface, const char *proto_name)
 {
-       const struct proto_handler *proto = NULL;
-
-       if (!proto_name) {
-               interface_add_error(iface, "proto", "NO_PROTO", NULL, 0);
-               return;
-       }
-
-       proto = get_proto_handler(proto_name);
-       if (!proto) {
-               interface_add_error(iface, "proto", "INVALID_PROTO", NULL, 0);
-               proto = &no_proto;
+       const struct proto_handler *proto = &no_proto;
+
+       if (proto_name) {
+               proto = get_proto_handler(proto_name);
+               if (!proto) {
+                       interface_add_error(iface, "proto", "INVALID_PROTO", NULL, 0);
+                       proto = &no_proto;
+               }
        }
 
        iface->proto_handler = proto;
        }
 
        iface->proto_handler = proto;