From 79368a64dbeba1bde4e03222ae82c1b22d66b37d Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 24 Jan 2012 22:39:11 +0100 Subject: [PATCH] make sure iface->proto_handler is always initialized --- proto.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/proto.c b/proto.c index c51637f..1a260cc 100644 --- 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) { - 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; -- 2.11.0