From patchwork Tue May 23 00:25:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 9741611 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3DF0860388 for ; Tue, 23 May 2017 00:48:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 308F226E51 for ; Tue, 23 May 2017 00:48:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 251B728779; Tue, 23 May 2017 00:48:48 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84BD126E51 for ; Tue, 23 May 2017 00:48:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759091AbdEWAsr (ORCPT ); Mon, 22 May 2017 20:48:47 -0400 Received: from gateway33.websitewelcome.com ([192.185.145.9]:33057 "EHLO gateway33.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758898AbdEWAsq (ORCPT ); Mon, 22 May 2017 20:48:46 -0400 X-Greylist: delayed 1414 seconds by postgrey-1.27 at vger.kernel.org; Mon, 22 May 2017 20:48:46 EDT Received: from cm6.websitewelcome.com (cm6.websitewelcome.com [108.167.139.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id D23AF594E3 for ; Mon, 22 May 2017 19:25:09 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cm6.websitewelcome.com with id PcR81v00P0V9LXg01cR9dE; Mon, 22 May 2017 19:25:09 -0500 Received: from [189.152.160.17] (port=59336 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.87) (envelope-from ) id 1dCxdM-0000Eo-I5; Mon, 22 May 2017 19:25:08 -0500 Date: Mon, 22 May 2017 19:25:07 -0500 From: "Gustavo A. R. Silva" To: Kukjin Kim , Krzysztof Kozlowski , Andi Shyti , Mark Brown Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] spi: add null check before pointer dereference Message-ID: <20170523002507.GA16670@embeddedgus> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.152.160.17 X-Exim-ID: 1dCxdM-0000Eo-I5 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.152.160.17]:59336 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 7 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add null check before dereferencing pointer desc Addresses-Coverity-ID: 1397997 Signed-off-by: Gustavo A. R. Silva --- drivers/spi/spi-s3c64xx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index b392cca..9f1013e 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -306,6 +306,12 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma, desc = dmaengine_prep_slave_sg(dma->ch, sgt->sgl, sgt->nents, dma->direction, DMA_PREP_INTERRUPT); + if (!desc) { + dev_err(&sdd->master->dev, + "%s:dmaengine_prep_slave_sg Failed\n", __func__); + return; + } + desc->callback = s3c64xx_spi_dmacb; desc->callback_param = dma;