From 73ea0284506a62324d7b7c92ec4982c2c5aff3b9 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 26 Oct 2011 19:30:05 +0200 Subject: [PATCH] ensure that iface->proto_handler gets initialized --- proto.c | 9 ++++++--- 1 file 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; } -- 2.11.0