Patch "tty: n_gsm: fix sometimes uninitialized warning in gsm_dlci_modem_output()" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tty: n_gsm: fix sometimes uninitialized warning in gsm_dlci_modem_output()

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tty-n_gsm-fix-sometimes-uninitialized-warning-in-gsm.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e85282d8f21109436a793e2b711aba30b2fabd1d
Author: Daniel Starke <daniel.starke@xxxxxxxxxxx>
Date:   Mon Apr 25 03:47:26 2022 -0700

    tty: n_gsm: fix sometimes uninitialized warning in gsm_dlci_modem_output()
    
    [ Upstream commit 19317433057dc1f2ca9a975e4e6b547282c2a5ef ]
    
    'size' may be used uninitialized in gsm_dlci_modem_output() if called with
    an adaption that is neither 1 nor 2. The function is currently only called
    by gsm_modem_upd_via_data() and only for adaption 2.
    Properly handle every invalid case by returning -EINVAL to silence the
    compiler warning and avoid future regressions.
    
    Fixes: c19ffe00fed6 ("tty: n_gsm: fix invalid use of MSC in advanced option")
    Cc: stable@xxxxxxxxxxxxxxx
    Reported-by: kernel test robot <lkp@xxxxxxxxx>
    Signed-off-by: Daniel Starke <daniel.starke@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220425104726.7986-1-daniel.starke@xxxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index c8ca00fad8e4..fd4a86111a6e 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -945,18 +945,21 @@ static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlci,
 {
 	u8 *dp = NULL;
 	struct gsm_msg *msg;
-	int size;
+	int size = 0;
 
 	/* for modem bits without break data */
-	if (dlci->adaption == 1) {
-		size = 0;
-	} else if (dlci->adaption == 2) {
-		size = 1;
+	switch (dlci->adaption) {
+	case 1: /* Unstructured */
+		break;
+	case 2: /* Unstructured with modem bits. */
+		size++;
 		if (brk > 0)
 			size++;
-	} else {
+		break;
+	default:
 		pr_err("%s: unsupported adaption %d\n", __func__,
 		       dlci->adaption);
+		return -EINVAL;
 	}
 
 	msg = gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux