From patchwork Mon Dec 23 18:34:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 3397871 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 6B6ED9F37A for ; Mon, 23 Dec 2013 18:35:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 60F8320688 for ; Mon, 23 Dec 2013 18:35:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 06FC0206DD for ; Mon, 23 Dec 2013 18:35:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757498Ab3LWSed (ORCPT ); Mon, 23 Dec 2013 13:34:33 -0500 Received: from jacques.telenet-ops.be ([195.130.132.50]:55986 "EHLO jacques.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757526Ab3LWSec (ORCPT ); Mon, 23 Dec 2013 13:34:32 -0500 Received: from ayla.of.borg ([84.193.72.141]) by jacques.telenet-ops.be with bizsmtp id 56aU1n00p32ts5g0J6aU6x; Mon, 23 Dec 2013 19:34:29 +0100 Received: from geert by ayla.of.borg with local (Exim 4.76) (envelope-from ) id 1VvAKi-0008Po-7t; Mon, 23 Dec 2013 19:34:28 +0100 From: Geert Uytterhoeven To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven , Hiep Cao Minh Subject: [PATCH 1/2] spi: rspi: Fix NULL pointer dereference on SH7757 Date: Mon, 23 Dec 2013 19:34:23 +0100 Message-Id: <1387823664-32318-1-git-send-email-geert+renesas@linux-m68k.org> 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=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 SH7757 doesn't pass platform data, in which case spi-rspi uses default parameters. However, commit 5ce0ba88650f2606244a761d92e2b725f4ab3583 ("spi: rcar: add Renesas QSPI support on RSPI") added a new user of the platform data, but forgot to check for its validity first, causing a NULL pointer dereference on SH7757. Add the missing check to fix this. Signed-off-by: Geert Uytterhoeven Cc: Hiep Cao Minh Acked-by: Simon Horman --- This fixes a regression introduced in v3.13-rc1 drivers/spi/spi-rspi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index cfdbb422a40a..9e0301014f48 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c @@ -948,8 +948,9 @@ static int rspi_probe(struct platform_device *pdev) INIT_WORK(&rspi->ws, rspi_work); init_waitqueue_head(&rspi->wait); - master->num_chipselect = rspi_pd->num_chipselect; - if (!master->num_chipselect) + if (rspi_pd && rspi_pd->num_chipselect) + master->num_chipselect = rspi_pd->num_chipselect; + else master->num_chipselect = 2; /* default */ master->bus_num = pdev->id;