From patchwork Wed Dec 3 11:25:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Baron X-Patchwork-Id: 5429151 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 976EA9F30B for ; Wed, 3 Dec 2014 11:34:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B0C3B20272 for ; Wed, 3 Dec 2014 11:34:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E213E2024F for ; Wed, 3 Dec 2014 11:33:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752715AbaLCLd6 (ORCPT ); Wed, 3 Dec 2014 06:33:58 -0500 Received: from remote.newtons4th.com ([81.138.188.183]:52668 "EHLO boxer.newtons4th.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751515AbaLCLdm (ORCPT ); Wed, 3 Dec 2014 06:33:42 -0500 X-Greylist: delayed 461 seconds by postgrey-1.27 at vger.kernel.org; Wed, 03 Dec 2014 06:33:42 EST Received: by boxer.newtons4th.com (Postfix, from userid 1000) id 7EB099E44B6; Wed, 3 Dec 2014 11:25:59 +0000 (GMT) From: Iain Baron To: Mark Brown Cc: linux-spi@vger.kernel.org, Iain Baron Subject: [PATCH] spi-altera: Fix NULL pointer dereference in spi_bitbang_transfer_one Date: Wed, 3 Dec 2014 11:25:49 +0000 Message-Id: <1417605949-11447-1-git-send-email-iain.baron@newtons4th.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP spi-altera.c is missing a bitbang setup_transfer callback to setup the clock and wordsize for the SPI transfer. This triggers a NULL pointer dereference in spi_bitbang_transfer_one. Provide the missing callback, which simply returns success, because the parameters are not configurable at runtime for this hardware. Signed-off-by: Iain Baron --- drivers/spi/spi-altera.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c index 595b62c..6b63f60 100644 --- a/drivers/spi/spi-altera.c +++ b/drivers/spi/spi-altera.c @@ -198,6 +198,12 @@ static irqreturn_t altera_spi_irq(int irq, void *dev) return IRQ_HANDLED; } +static int altera_spi_setup_transfer(struct spi_device *spi, + struct spi_transfer *t) +{ + return 0; +} + static int altera_spi_probe(struct platform_device *pdev) { struct altera_spi_platform_data *platp = dev_get_platdata(&pdev->dev); @@ -224,6 +230,7 @@ static int altera_spi_probe(struct platform_device *pdev) return err; hw->bitbang.chipselect = altera_spi_chipsel; hw->bitbang.txrx_bufs = altera_spi_txrx; + hw->bitbang.setup_transfer = altera_spi_setup_transfer; /* find and map our resources */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);