From patchwork Thu Mar 14 06:42:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10852221 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 5ACC413B5 for ; Thu, 14 Mar 2019 06:42:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 487D62A1C2 for ; Thu, 14 Mar 2019 06:42:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BE722A1C6; Thu, 14 Mar 2019 06:42:25 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 DFF882A1C2 for ; Thu, 14 Mar 2019 06:42:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726530AbfCNGmL (ORCPT ); Thu, 14 Mar 2019 02:42:11 -0400 Received: from mta-p8.oit.umn.edu ([134.84.196.208]:47692 "EHLO mta-p8.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726748AbfCNGmK (ORCPT ); Thu, 14 Mar 2019 02:42:10 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p8.oit.umn.edu (Postfix) with ESMTP id 204407CD for ; Thu, 14 Mar 2019 06:42:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p8.oit.umn.edu ([127.0.0.1]) by localhost (mta-p8.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bWd51gtKv_B6 for ; Thu, 14 Mar 2019 01:42:09 -0500 (CDT) Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p8.oit.umn.edu (Postfix) with ESMTPS id E5940C3F for ; Thu, 14 Mar 2019 01:42:08 -0500 (CDT) Received: by mail-io1-f72.google.com with SMTP id e1so3508674iod.23 for ; Wed, 13 Mar 2019 23:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=djczHsp7CBHav0Hh11ppVz3UNxAxa2JmLPeSFnm+Eo0=; b=kmyO8qFyE1SjY3hAgU214XoSWSUVUuJ2n01JQgoIQgmEZXZ7rMRBfBBPpwWcyvO2+7 aNuTUlaeMfM0GNCy+i8PW53dEgjpJBNN5dhIHVyhUvGqb2jOmb7hzlCXGT1xXioXgtu7 RnaBOcb3fCWKpzBEmxCQMS/yPKk2CfAU4u+D2t1J06uJE3sy1pN2ZFkFGdy5PgMpY8zq UkGpugDiA5/I8EyMpqC0UgR5PyK59zThunc2BKLk2QfjuV50ZUmcbpcZPK/mzbKFDG22 YblhXV5KeRY/Zbuxq7uMDO8HOg4BRA1wjzlj+iUtxm4qQhRC8dfRv5YWk2zaKDGFBFXo jE2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=djczHsp7CBHav0Hh11ppVz3UNxAxa2JmLPeSFnm+Eo0=; b=DSqAbUs1rOyxDdsPxjgfd9pItIRQPn1ej3pfDBCz9ZiXvzwD8UH5nc485lV9rLbWz6 AjhHQeuS7ID1BqsPX0kNkHmJJfHUDyN+PTdWW02EVrStrD8gjeMq0kv6/uHk0CtHurMV CX72wja0l9xYMYyarHWB275w0o721RFP1As65tGNvqMjmL5KZDy8r8v4Pc1I5DUL4TMm NyBwclSTXCudEyx4k0GQpq0m6t4aweIg6IPp7EUH7BNs+7YceivRO4gJ5PjLZ9orpMHf xX30LCLg8xw90SR0aWOtGTlZK4+4HkWd9E+y9/0UZpO2h4hgW+l4ZHHkknTIwIct4NMr Y/Lg== X-Gm-Message-State: APjAAAV8XqoJdMfl6h0Nq67Q0t4G7hKCMdeZbl0XLY8xco604uh/o5u7 KuKQvsVjFNAOqDQ2YGqpuvygT9abnY0+2+lHzXbZgI9nsWgH7AR5F004ItGdtMYCPKz6RzFQqom 8/RYy/+/lu36hSfLxuKlz7LlL X-Received: by 2002:a5d:9455:: with SMTP id x21mr26922702ior.250.1552545728500; Wed, 13 Mar 2019 23:42:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFWKuN/f6S7G/2+tGu7Ix/FMi6al4o5VH9Mwnfc1piVdtuHnK72QxIfLkreCKIJli6pvenZQ== X-Received: by 2002:a5d:9455:: with SMTP id x21mr26922698ior.250.1552545728284; Wed, 13 Mar 2019 23:42:08 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id p4sm6132871ioj.36.2019.03.13.23.42.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 23:42:07 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Kukjin Kim , Krzysztof Kozlowski , Andi Shyti , Mark Brown , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: fix NULL pointer dereferences by checking dmaengine_prep_slave_sg Date: Thu, 14 Mar 2019 01:42:01 -0500 Message-Id: <20190314064202.14864-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 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 In case dmaengine_prep_slave_sg fails, the fix returns to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu --- drivers/spi/spi-s3c64xx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 7b7151ec14c8..3a5f161ce558 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -293,6 +293,8 @@ 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) + return; desc->callback = s3c64xx_spi_dmacb; desc->callback_param = dma;