[PATCH] tty: n_gsm: return -EINVAL when adaption is not supported

From: Tom Rix
Date: Tue Apr 26 2022 - 08:06:09 EST


The clang build fails with
n_gsm.c:940:13: error: variable 'size' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
} else if (dlci->adaption == 2) {
^~~~~~~~~~~~~~~~~~~

The else should return an error, so return -EINVAL.

Signed-off-by: Tom Rix <trix@xxxxxxxxxx>
---
drivers/tty/n_gsm.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index b0762d2fa8d6..3b8c65f66d64 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -944,6 +944,7 @@ static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlci,
} else {
pr_err("%s: unsupported adaption %d\n", __func__,
dlci->adaption);
+ return -EINVAL;
}

msg = gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype);
--
2.27.0