From: Felix Fietkau Date: Tue, 24 Jan 2012 21:39:11 +0000 (+0100) Subject: make sure iface->proto_handler is always initialized X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=commitdiff_plain;h=79368a64dbeba1bde4e03222ae82c1b22d66b37d make sure iface->proto_handler is always initialized --- 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;