summaryrefslogtreecommitdiffhomepage
path: root/proto.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-10-26 19:30:05 +0200
committerFelix Fietkau <nbd@openwrt.org>2011-10-26 19:30:05 +0200
commit73ea0284506a62324d7b7c92ec4982c2c5aff3b9 (patch)
tree5c69e6ef2c3ddd4e913351b90e83c93c718b8973 /proto.c
parent76a6865acbed4df30d57bf57f62522c681081152 (diff)
ensure that iface->proto_handler gets initialized
Diffstat (limited to 'proto.c')
-rw-r--r--proto.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/proto.c b/proto.c
index bd3b09a..c51637f 100644
--- a/proto.c
+++ b/proto.c
@@ -160,9 +160,10 @@ proto_init_interface(struct interface *iface, struct blob_attr *attr)
const struct proto_handler *proto = iface->proto_handler;
struct interface_proto_state *state = NULL;
- if (proto)
- state = proto->attach(proto, iface, attr);
+ if (!proto)
+ proto = &no_proto;
+ state = proto->attach(proto, iface, attr);
if (!state) {
state = no_proto.attach(&no_proto, iface, attr);
state->cb = invalid_proto_handler;
@@ -183,8 +184,10 @@ proto_attach_interface(struct interface *iface, const char *proto_name)
}
proto = get_proto_handler(proto_name);
- if (!proto)
+ if (!proto) {
interface_add_error(iface, "proto", "INVALID_PROTO", NULL, 0);
+ proto = &no_proto;
+ }
iface->proto_handler = proto;
}