From patchwork Fri May 6 07:24:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 9029421 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2FB5B9F39D for ; Fri, 6 May 2016 07:25:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C1C7020381 for ; Fri, 6 May 2016 07:25:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C02E720376 for ; Fri, 6 May 2016 07:25:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758178AbcEFHZX (ORCPT ); Fri, 6 May 2016 03:25:23 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:58117 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756738AbcEFHZT (ORCPT ); Fri, 6 May 2016 03:25:19 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O6Q00DG5VA35Q80@mailout1.w1.samsung.com>; Fri, 06 May 2016 08:25:16 +0100 (BST) X-AuditID: cbfec7f5-f792a6d000001302-cc-572c46db8ad6 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id E5.8E.04866.BD64C275; Fri, 6 May 2016 08:25:15 +0100 (BST) Received: from AMDC2174.DIGITAL.local ([106.120.53.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O6Q00AUIV9W5150@eusync3.samsung.com>; Fri, 06 May 2016 08:25:15 +0100 (BST) From: Krzysztof Kozlowski To: Kukjin Kim , Krzysztof Kozlowski , MyungJoo Ham , Chanwoo Choi , Dmitry Torokhov , Richard Purdie , Jacek Anaszewski , Lee Jones , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Liam Girdwood , Mark Brown , Alessandro Zummo , Alexandre Belloni , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pm@vger.kernel.org, rtc-linux@googlegroups.com Cc: r.baldyga@hackerion.com, Marek Szyprowski , stable@vger.kernel.org, Bartlomiej Zolnierkiewicz Subject: [PATCH v6 1/9] input: max8997-haptic: Fix NULL pointer dereference Date: Fri, 06 May 2016 09:24:56 +0200 Message-id: <1462519504-3092-1-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1462519289-2356-2-git-send-email-k.kozlowski@samsung.com> References: <1462519289-2356-2-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBIsWRmVeSWpSXmKPExsVy+t/xq7q33XTCDTbNU7ZYcvEqu0XHtcVM FhtnrGe1mPrwCZvF9S/PWS0mPXnPbDH/yDlWi8OLXjBaTFw5mdmi9+pzRovXLwwt+h+/Zra4 //Uoo8W3Kx1MFpseX2O1uPnpG6vF5V1z2Cy2vlnHaPG59wijxYzz+5gs1h65y25xu3EFm8Xd f58YLXbvespqsb+zg9Hi9O4SiwUbHzE6SHs82XSR0WPnrLvsHnsmnmTzOLLzGJvH5hVaHptW dbJ53Lm2B8hbUu+xZ/4PVo++LasYPabP+8nk8XmTXABPFJdNSmpOZllqkb5dAlfG1tPzGAvu CVV8vnOHqYFxmkAXIyeHhICJxM4HR1ggbDGJC/fWs3UxcnEICSxllPjc8Yodwmlkkvi87A0z SBWbgLHE5uVLwKpEBD6ySVx+/4wRxGEWmMEosfn+WnaQKmEBb4n3KzaAdbAIqEr0vW8H2sHB wSvgJvG8IxJinZzEyWOTWUFsTgF3iTkP54OdIQRUsvD+L8YJjLwLGBlWMYqmliYXFCel5xrp FSfmFpfmpesl5+duYoTE19cdjEuPWR1iFOBgVOLhzTipHS7EmlhWXJl7iFGCg1lJhNfPRSdc iDclsbIqtSg/vqg0J7X4EKM0B4uSOO/MXe9DhATSE0tSs1NTC1KLYLJMHJxSDYxW0lrydzUy Nk59YaEivdcnfvLEWhMlfXYvizeXuHb+8Lz4OoD5oXZRsP0cdvOLB/0Y1Y4nVTXcKLkwf/+E CXz/nGoC9q9ZuflQ6A2V5+vkHzcb2cpUc+Vp8vMqpG+0mvLU4tzs/08uL14cWGOlGfrBTE7r kH/Qtq73e15eiOqaNnniac978aVKLMUZiYZazEXFiQCQt76OqwIAAA== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-9.0 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 From: Marek Szyprowski NULL pointer derefence happens when booting with DTB because the platform data for haptic device is not set in supplied data from parent MFD device. The MFD device creates only platform data (from Device Tree) for itself, not for haptic child. Unable to handle kernel NULL pointer dereference at virtual address 0000009c pgd = c0004000 [0000009c] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM (max8997_haptic_probe) from [] (platform_drv_probe+0x4c/0xb0) (platform_drv_probe) from [] (driver_probe_device+0x214/0x2c0) (driver_probe_device) from [] (__driver_attach+0xac/0xb0) (__driver_attach) from [] (bus_for_each_dev+0x68/0x9c) (bus_for_each_dev) from [] (bus_add_driver+0x1a0/0x218) (bus_add_driver) from [] (driver_register+0x78/0xf8) (driver_register) from [] (do_one_initcall+0x90/0x1d8) (do_one_initcall) from [] (kernel_init_freeable+0x15c/0x1fc) (kernel_init_freeable) from [] (kernel_init+0x8/0x114) (kernel_init) from [] (ret_from_fork+0x14/0x3c) Signed-off-by: Marek Szyprowski Cc: Fixes: 104594b01ce7 ("Input: add driver support for MAX8997-haptic") [k.kozlowski: Write commit message, add CC-stable] Signed-off-by: Krzysztof Kozlowski --- drivers/input/misc/max8997_haptic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/input/misc/max8997_haptic.c b/drivers/input/misc/max8997_haptic.c index a806ba3818f7..8d6326d7e7be 100644 --- a/drivers/input/misc/max8997_haptic.c +++ b/drivers/input/misc/max8997_haptic.c @@ -255,12 +255,14 @@ static int max8997_haptic_probe(struct platform_device *pdev) struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); const struct max8997_platform_data *pdata = dev_get_platdata(iodev->dev); - const struct max8997_haptic_platform_data *haptic_pdata = - pdata->haptic_pdata; + const struct max8997_haptic_platform_data *haptic_pdata = NULL; struct max8997_haptic *chip; struct input_dev *input_dev; int error; + if (pdata) + haptic_pdata = pdata->haptic_pdata; + if (!haptic_pdata) { dev_err(&pdev->dev, "no haptic platform data\n"); return -EINVAL;