[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1555139666-948-9-git-send-email-hofrat@osadl.org>
Date: Sat, 13 Apr 2019 09:14:20 +0200
From: Nicholas Mc Guire <hofrat@...dl.org>
To: Russell King <linux@...linux.org.uk>
Cc: Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
NXP Linux Team <linux-imx@....com>,
Mark Brown <broonie@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>,
Tony Lindgren <tony@...mide.com>,
Mike Rapoport <rppt@...ux.vnet.ibm.com>,
Janusz Krzysztofik <jmkrzyszt@...il.com>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Nicholas Mc Guire <hofrat@...dl.org>
Subject: [PATCH] ARM: u300: add missing check for kmalloc
kmalloc return for bigrxbuf_virtual was not being checked - in case
of failure set status, cleanup bigtxbuf_virtual and baile out.
Signed-off-by: Nicholas Mc Guire <hofrat@...dl.org>
Fixes: c7c8c78fdf6e ("ARM: 5667/3: U300 SSP/SPI board setup and test")
---
Issue found with experimental coccinelle script
Not sure about the checkpatch message:
CHECK: Comparison to NULL could be written "!bigrxbuf_virtual"
#32: FILE: arch/arm/mach-u300/dummyspichip.c:67:
+ if (bigrxbuf_virtual == NULL) {
As the current check for bigtxbuf_virtual uses == NULL that
was retained for consistency here.
Patch was compile tested with: u300_defconfig (implies MACH_U300_SPIDUMMY=y)
Patch is against 4.18 (localversion-next is next-20180824)
arch/arm/mach-u300/dummyspichip.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm/mach-u300/dummyspichip.c b/arch/arm/mach-u300/dummyspichip.c
index 68fe986..ff293ee 100644
--- a/arch/arm/mach-u300/dummyspichip.c
+++ b/arch/arm/mach-u300/dummyspichip.c
@@ -62,7 +62,13 @@ static ssize_t dummy_looptest(struct device *dev,
status = -ENOMEM;
goto out;
}
+
bigrxbuf_virtual = kmalloc(DMA_TEST_SIZE, GFP_KERNEL);
+ if (bigrxbuf_virtual == NULL) {
+ kfree(bigtxbuf_virtual);
+ status = -ENOMEM;
+ goto out;
+ }
/* Fill TXBUF with some happy pattern */
memset(bigtxbuf_virtual, 0xAA, DMA_TEST_SIZE);
--
2.1.4
Powered by blists - more mailing lists