From patchwork Fri Aug 24 10:28:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 10575457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63AC21390 for ; Fri, 24 Aug 2018 15:06:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52FEC285FC for ; Fri, 24 Aug 2018 15:06:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46D0928669; Fri, 24 Aug 2018 15:06:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SUSPICIOUS_RECIPS autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 99148285FC for ; Fri, 24 Aug 2018 15:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=lsCrsJmkMWh/V4673sgUvj6SrevEgKF/1oQ5n14sx9I=; b=aPR gUVPnURF0sw+t8uR+VzasxdrZlbA5eaOgylcksHGy8YVo1SKlayg7+lWDADA2DpdZa2C3v2G6Eyjq ZxJsqil/9hVqqvN3qRmQVS4K8HJUoJ1L+6GDkNMUJlNlTn1XUiTHBotosQoHC6SfjaJ1GNQmFMwS6 T5H1SL3S+MMftrwHAFzOsX6ACAYO8mtZfJ+argAv8hgCTaqgO2WwuHTbm5s0q7h7F02uYrzHEslWc 70KVjfFjS8TwVsMf7JJBZBAHRtFs6yPhsIC7viYFsihJaIuKKGsKVbaDRpcQ3AazGilVFhy7tssfT DuvFsp/B8qLpxWUgCHuhYOGrtDYwQpw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ftDfa-0004Qo-Q2; Fri, 24 Aug 2018 15:06:38 +0000 Received: from www.osadl.org ([62.245.132.105]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ft9Rr-0001Bj-GR for linux-arm-kernel@lists.infradead.org; Fri, 24 Aug 2018 10:41:35 +0000 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id w7OAUI7C006666; Fri, 24 Aug 2018 12:30:18 +0200 From: Nicholas Mc Guire To: Linus Walleij Subject: [PATCH] ARM: u300: add missing check for kmalloc Date: Fri, 24 Aug 2018 12:28:54 +0200 Message-Id: <1535106534-983-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180824_034008_265936_11905FA4 X-CRM114-Status: UNSURE ( 9.26 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Mc Guire , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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);