net/mqtt: Improve error handling in mqtt_rx_connack routine

Avoid undesired behaviors by exiting once an error is detected.

Change-Id: Id8e6accd6cd096274fe1c40a615d290967f1d4b9
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
This commit is contained in:
Flavio Santes 2017-01-01 16:12:39 -06:00 committed by Tomasz Bursztyka
commit 8619d9d625

View file

@ -415,6 +415,7 @@ int mqtt_rx_connack(struct mqtt_ctx *ctx, struct net_buf *rx, int clean_session)
rc = 0;
} else {
rc = -EINVAL;
goto exit_connect;
}
break;
/* previous session */
@ -423,7 +424,7 @@ int mqtt_rx_connack(struct mqtt_ctx *ctx, struct net_buf *rx, int clean_session)
/* FALLTHROUGH */
default:
rc = -EINVAL;
break;
goto exit_connect;
}
ctx->connected = 1;