Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1276805

[PATCH] serial: ifx6x60: avoid uninitialized variable use

Path csiph.com!goblin3!goblin2!goblin.stu.neva.ru!aioe.org!bofh.it!news.nic.it!robomod
From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject [PATCH] serial: ifx6x60: avoid uninitialized variable use
Date Tue, 24 Nov 2015 23:10:01 +0100
Message-ID <qytWF-5Av-5@gated-at.bofh.it> (permalink)
X-Original-To gregkh@linuxfoundation.org
User-Agent KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; )
MIME-Version 1.0
Content-Transfer-Encoding 7Bit
Content-Type text/plain; charset="us-ascii"
X-Provags-ID V03:K0:xkU5PtZha1WJcMLQnwosIC9FxF7kDpulfFKi5bluIK7UEkpAKg2 78Dvdsi2otl9QRBnzdq6TVNh5gm3MhdycxgUawPFy7IzgoMpott+IUyzcp5ZwX249XFWOi6 DwpUeBn3O08Pcq5aY09Y6eSG/hH26CKFSiBKM3qSoOg/aNBSAqPObG0NNHgsJvB4jAmBOic ZlhP1Gz6rKsVhOXYwX/lg==
X-Ui-Out-Filterresults notjunk:1;V01:K0:AKEJWrKgYck=:5Nfd4XmeZYyBaP/ykRfLx+ uS+7RnN9yb9vPkw5ErWYUJvv8f2yfjzR1C07QS7Hl+/wCyY/Dx/O1vMHzbGOVojYdbzgnYOvN AueP7NcbKZat/Pjq7lL9M9f/gPKz3jz/jR4V3u5+62a3ocrEtazfHFCtJJlovkPed4OFikrDB mMcH+vXHt5jyAQQ8EehyqranF3dkXdcrD1Rn+abYZBViUAFKxydOhydcccopICeVSR2qOfhHQ jTQ8Cuqadu41mxeLenLqcSWlJaZlvCeWQqnudhoFfi9J/dinL6EDN1eg5iQbmxlXxZZ2EbDD1 JDKJ/l08tKl4WpqTnA329S28kZI1NN2Pkho+vm0PNBXNdJP5euGCfWp+qVg3HgDu2tILL6mLZ OTwUzfkkkCPFOX1/zv2vMLax+S1jR1FsIao4aAOXGInTawOPZhCvFWWcl7TUw1QD/LHVIkJWa htA+qGbFPajYvRajlY9ceXabqcJ3Y6CVUkc86jZq3UgdbhdYCJ0gz3PTk7ZrGFqn07d7ecxzC udlEKN9SBmOU/ETJ5wjcB2JCGsLmqOUj42Zet6BnuP426KnLESB1I833lPrywjXPepqCa2pYM GvgAU+Tzfk0HdiXLk8ao9wW3C3RE2N0Yb9FVkfQPybpuvB4BsNVjbPgJFqO3NAMrYJWwSsLLN s0q9+2iFrZi5E3vt1V1QCzbIxbXLc5XY047ifqpXyrpS5mdzg8KoCb0ozTQb1Iu4FOkU7/bqs lh6lRNBiC3bbKYWz
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 40
Organization linux.* mail to news gateway
X-Original-Cc Jiri Slaby <jslaby@suse.com>, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Jun <jun.d.chen@intel.com>, channing <chao.bi@intel.com>, Russ Gorby <russ.gorby@intel.com>, Vasiliy Kulikov <segoon@openwall.com>
X-Original-Date Tue, 24 Nov 2015 23:04 +0100
X-Original-Message-ID <3244991.qANsXoqoKs@wuerfel>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1276805

Show key headers only | View raw


gcc warns about a potential use of an uninitialized variable in this driver:

drivers/tty/serial/ifx6x60.c: In function 'ifx_spi_complete':
drivers/tty/serial/ifx6x60.c:713:6: warning: 'more' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (more || ifx_dev->spi_more || queue_length > 0 ||

Unlike a lot of other such warnings, this one is correct and describes
an actual problem in the handling of the "IFX_SPI_HEADER_F" result code.

This appears to be a result from a restructuring of the driver that
dates back to before it was merged in the kernel, so it's impossible
to know where it went wrong. I also don't know what that result code
means, so I have no idea if setting 'more' to zero is the correct
solution, but at least it makes the behavior reproducible rather than
depending on whatever happens to be on the kernel stack.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Cc everyone who contributed non-cleanup patches to this driver,
maybe someone has more insight into the operation of the driver than
I have and can comment on whether this is the right fix or not.

diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
index 88246f7e435a..5d18442e42ba 100644
--- a/drivers/tty/serial/ifx6x60.c
+++ b/drivers/tty/serial/ifx6x60.c
@@ -397,6 +397,7 @@ static int ifx_spi_decode_spi_header(unsigned char *buffer, int *length,
 		*received_cts = 0;
 		return IFX_SPI_HEADER_0;
 	} else if (h1 == 0xffff && h2 == 0xffff) {
+		*received_cts = 0;
 		/* spi_slave_cts remains as it was */
 		return IFX_SPI_HEADER_F;
 	}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH] serial: ifx6x60: avoid uninitialized variable use Arnd Bergmann <arnd@arndb.de> - 2015-11-24 23:10 +0100
  Re: [PATCH] serial: ifx6x60: avoid uninitialized variable use Arnd Bergmann <arnd@arndb.de> - 2015-11-25 11:10 +0100

csiph-web