linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Mc Guire <hofrat@osadl.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Russell King <linux@armlinux.org.uk>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Nicholas Mc Guire <hofrat@osadl.org>
Subject: [PATCH] ARM: u300: add missing check for kmalloc
Date: Fri, 24 Aug 2018 12:28:54 +0200	[thread overview]
Message-ID: <1535106534-983-1-git-send-email-hofrat@osadl.org> (raw)

 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@osadl.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


             reply	other threads:[~2018-08-24 10:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-24 10:28 Nicholas Mc Guire [this message]
2018-09-05  9:09 ` [PATCH] ARM: u300: add missing check for kmalloc Linus Walleij
2018-09-05 11:20   ` Nicholas Mc Guire
2019-04-13  7:14 [PATCH 0/4] ARM: imx legacy: cleanups Nicholas Mc Guire
2019-04-13  7:14 ` [PATCH] ARM: u300: add missing check for kmalloc Nicholas Mc Guire
2019-04-23 10:26   ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1535106534-983-1-git-send-email-hofrat@osadl.org \
    --to=hofrat@osadl.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).