net: Fix memory leak in the proto_register function