From patchwork Tue Oct 21 05:57:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Ungerer X-Patchwork-Id: 5110701 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 76D95C11AD for ; Tue, 21 Oct 2014 06:17:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A332220158 for ; Tue, 21 Oct 2014 06:17:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9F812011E for ; Tue, 21 Oct 2014 06:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753466AbaJUGRa (ORCPT ); Tue, 21 Oct 2014 02:17:30 -0400 Received: from nskntqsrv01p.mx.bigpond.com ([61.9.168.231]:33616 "EHLO nskntqsrv01p.mx.bigpond.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753232AbaJUGRW (ORCPT ); Tue, 21 Oct 2014 02:17:22 -0400 X-Greylist: delayed 1156 seconds by postgrey-1.27 at vger.kernel.org; Tue, 21 Oct 2014 02:17:21 EDT Received: from nskntcmgw06p ([61.9.169.166]) by nskntmtas05p.mx.bigpond.com with ESMTP id <20141021055802.HZNF19653.nskntmtas05p.mx.bigpond.com@nskntcmgw06p>; Tue, 21 Oct 2014 05:58:02 +0000 Received: from goober.accelecon.com ([149.135.16.88]) by nskntcmgw06p with BigPond Outbound id 5hy11p00q1u0AeD01hy1uM; Tue, 21 Oct 2014 05:58:02 +0000 X-Authority-Analysis: v=2.0 cv=RsdH3VaK c=1 sm=1 a=tpHzvNDyw14p4wpd1xf5Bw==:17 a=aFTPlZ8mLXYA:10 a=abLpnCq0AAAA:8 a=pGLkceISAAAA:8 a=ahB0kfRK5IPk0LVrccQA:9 a=8itaGvuMXGQA:10 a=MSl-tDqOz04A:10 a=tpHzvNDyw14p4wpd1xf5Bw==:117 From: gerg@uclinux.org To: broonie@kernel.org, linux-spi@vger.kernel.org, karl.beldan@gmail.com Cc: Greg Ungerer Subject: [PATCH] spi: orion: fix potential NULL pointer de-reference Date: Tue, 21 Oct 2014 15:57:48 +1000 Message-Id: <1413871068-32174-1-git-send-email-gerg@uclinux.org> X-Mailer: git-send-email 1.9.1 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Greg Ungerer It's possible that the call to of_match_device() (introduced in commit df59fa7f ["spi: orion: support armada extended baud rates"]) may return a NULL if there is no match in the device tree (or perhaps no device tree at all). Check the return pointer and set the local device data to the lowest common denominator orion device data if it is NULL. Reported-by: Karl Beldan Signed-off-by: Greg Ungerer --- drivers/spi/spi-orion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index 835cdda..c76b7d7 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -454,7 +454,7 @@ static int orion_spi_probe(struct platform_device *pdev) spi->master = master; of_id = of_match_device(orion_spi_of_match_table, &pdev->dev); - devdata = of_id->data; + devdata = (of_id) ? of_id->data : &orion_spi_dev_data; spi->devdata = devdata; spi->clk = devm_clk_get(&pdev->dev, NULL);