From patchwork Thu Feb 25 20:47:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102681 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp365627lbc; Thu, 25 Feb 2016 12:48:54 -0800 (PST) X-Received: by 10.98.1.197 with SMTP id 188mr65867657pfb.8.1456433334290; Thu, 25 Feb 2016 12:48:54 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si14582956pfi.163.2016.02.25.12.48.54; Thu, 25 Feb 2016 12:48:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750790AbcBYUsw (ORCPT + 1 other); Thu, 25 Feb 2016 15:48:52 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:64101 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750763AbcBYUsw (ORCPT ); Thu, 25 Feb 2016 15:48:52 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue102) with ESMTPA (Nemesis) id 0M0z5L-1ZeBsp3nsF-00vA1C; Thu, 25 Feb 2016 21:48:13 +0100 From: Arnd Bergmann To: Greg Kroah-Hartman Cc: linux-arm-kernel@lists.infradead.org, Russ Gorby , Alan Cox , Arnd Bergmann , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] serial: ifx6x60: avoid uninitialized variable use Date: Thu, 25 Feb 2016 21:47:57 +0100 Message-Id: <1456433283-3761559-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:sIPplRCxfLNYIiDahwOuc2yPp+1M7BG7MT5glXBveIHnKVGEyUd HpDwpmwmZSkbTIgCIZ6jsaKxiBjcnvEFCyBuArWw5jPZqH9QWx8GFiJMo5wxCztElZquc0l 0PVVrQGnHq1KVLAohFt5okHfZGhz4o5IEOoERd9jTPDBbb1rnMAzhm2NChtqe3T7+03qo/W iEbIooXVPQsuVnfEAaz0w== X-UI-Out-Filterresults: notjunk:1; V01:K0:XNolTJCjITQ=:/J/dQ94hXk0m9XQ/ze3ieR 5n5wDlUaHj8qAZMv6wgAfTTTbJaGjLQQLCzhFSM0lwafBIT80tSub6RwokKCiM8I5Cbl9eaNk 1KDq3eKOrF5xcwO9nmb3WgXFZdNs+1MdLkhb92/PJ3chaanZKxRocKd2ASyelQgse6rGvyc/4 AsPWbIeijt1C2vMATpRL1BKA5nibwsfyNH/o4QKhCmZQ9eZ2Qke9G6ldqUKXxymngPk2RoN6p ocVdAIOyEliZW79enmFRREguf38LAR+FLLp7kPxJkTnH1mZZopR8s3kXeiKALJ/XdleDmI/Cl Vr5G8CYbU3i9EGuySj2AnAkRWfNxtncIUIz/yGdx/sbr+1b//PeKcMBvDg97GJ1/oU1J34ehH X0SW7EXafGY/w9TOHrTRTNkLQit8kHVtLpgqzeNqeuxfcoQEQsSj+mIlOQopyNq9plyY5lkoL r3m0iolnU3ojRpwfDqQnYGxRerT0xxgu0TZ3PMyDruzM7cv1ds8BxYehEuXtojieEIU06/8HE 2d1TNmPObz9dPFyu+yv2wmSqMkMS7z0F9qRSlHVHTlu+iPawNcpZIeEBqp2clAttNosz/ZlpP bjOyhlu3qnGFp+1fSOZC7ESGZuffpgnCpJqEl+GLMS54p3XUKlb66b7cQGmTWY77Pa5yDTiu4 xn21OA1A18DD4qszNyOF2f0uMgdBtoK2t142FFT3L1euSi9kq66DyL4SGsXsGRuMD1AY= Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 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. This patch initializes the 'more' variable to zero in each of the three code paths that could result in undefined behavior before, which is more explicit than initializing it at the start of the function. Signed-off-by: Arnd Bergmann --- drivers/tty/serial/ifx6x60.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c index 88246f7e435a..2085a6cfa44b 100644 --- a/drivers/tty/serial/ifx6x60.c +++ b/drivers/tty/serial/ifx6x60.c @@ -395,8 +395,10 @@ static int ifx_spi_decode_spi_header(unsigned char *buffer, int *length, if (h1 == 0 && h2 == 0) { *received_cts = 0; + *more = 0; return IFX_SPI_HEADER_0; } else if (h1 == 0xffff && h2 == 0xffff) { + *more = 0; /* spi_slave_cts remains as it was */ return IFX_SPI_HEADER_F; } @@ -688,6 +690,7 @@ static void ifx_spi_complete(void *ctx) ifx_dev->rx_buffer + IFX_SPI_HEADER_OVERHEAD, (size_t)actual_length); } else { + more = 0; dev_dbg(&ifx_dev->spi_dev->dev, "SPI transfer error %d", ifx_dev->spi_msg.status); }