From patchwork Fri May 6 07:21:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 9029351 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A410ABF29F for ; Fri, 6 May 2016 07:21:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA52620373 for ; Fri, 6 May 2016 07:21:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C012820382 for ; Fri, 6 May 2016 07:21:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758102AbcEFHVr (ORCPT ); Fri, 6 May 2016 03:21:47 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:26280 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751733AbcEFHVm (ORCPT ); Fri, 6 May 2016 03:21:42 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O6Q00NLYV413F80@mailout3.w1.samsung.com>; Fri, 06 May 2016 08:21:38 +0100 (BST) X-AuditID: cbfec7f5-f792a6d000001302-f2-572c4601e9b2 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 22.0E.04866.1064C275; Fri, 6 May 2016 08:21:37 +0100 (BST) Received: from AMDC2174.DIGITAL.local ([106.120.53.17]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O6Q00ITQV3WJS00@eusync4.samsung.com>; Fri, 06 May 2016 08:21:37 +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:21:21 +0200 Message-id: <1462519289-2356-2-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1462519289-2356-1-git-send-email-k.kozlowski@samsung.com> References: <1462519289-2356-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBIsWRmVeSWpSXmKPExsVy+t/xa7qMbjrhBlt+mlosuXiV3aLj2mIm i40z1rNaTH34hM3i+pfnrBaTnrxntph/5ByrxeFFLxgtJq6czGzRe/U5o8XrF4YW/Y9fM1vc /3qU0eLblQ4mi02Pr7Fa3Pz0jdXi8q45bBZb36xjtPjce4TRYsb5fUwWa4/cZbe43biCzeLu v0+MFrt3PWW12N/ZwWhxeneJxYKNjxgdpD2ebLrI6LFz1l12jz0TT7J5HNl5jM1j8wotj02r Otk87lzbA+QtqffYM/8Hq0ffllWMHtPn/WTy+LxJLoAnissmJTUnsyy1SN8ugStj6+l5jAX3 hCo+37nD1MA4TaCLkZNDQsBE4uyiJiYIW0ziwr31bF2MXBxCAksZJeY372SGcBqZJKafvcQO UsUmYCyxefkSsCoRgY9sEpffP2MEcZgFZjBKbL6/FqxKWMBb4v2KDcwgNouAqsTkl4dYuhg5 OHgF3CRmzWCFWCcncfLYZDCbU8BdYv26VSwgthBQydKfn5gmMPIuYGRYxSiaWppcUJyUnmuk V5yYW1yal66XnJ+7iRESX193MC49ZnWIUYCDUYmHN+OkdrgQa2JZcWXuIUYJDmYlEV4/F51w Id6UxMqq1KL8+KLSnNTiQ4zSHCxK4rwzd70PERJITyxJzU5NLUgtgskycXBKNTD6bAmQmd/f 4XfU+l2O2JSK804/fvv/YW1sNlcqrL9aILY1YYXl8Xbbp9ve1G3i27Z86tKkI+puk87vnjST eXKT/Av3NzK7vIpuS3Iek7w8odsqeVtmEKfbXPn74g3V7G/vGglMNwlaGCx2i1nszKwpilp7 7tmz/du/d55czMF9htFJOlJ7wv2UWIozEg21mIuKEwH+T/eQqwIAAA== 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;