[wilink8-wlan/build-utilites.git] / patches / kernel_patches / imx-3.10.53-android-5.0.0_1.0.0-ga / 0015-drivers-misc-ti-st-fix-null-pointer-exception-in-st_.patch
1 From a4b96024f961a89f72bdc422f8ba4c8b64349969 Mon Sep 17 00:00:00 2001
2 From: Gigi Joseph <gigi.joseph@gmail.com>
3 Date: Fri, 9 Jan 2015 03:48:29 +0000
4 Subject: [PATCH 15/15] drivers: misc: ti-st: fix null pointer exception in
5 st_kim_ref()
7 st_kim_ref() does not take care of the fact that platform_get_drvdata() might return NULL. On AM437x EVM, this causes the platform to stop booting as soon as the module is inserted.
9 This patch fixes the issue by checking for NULL return value. Oops log follows.
11 I have not tested BT functionality after this patch. But at least the platform boots now.
13 [ 12.675697] Unable to handle kernel NULL pointer dereference at virtual address 0000005c
14 [ 12.684310] pgd = c0004000
15 [ 12.687157] [0000005c] *pgd=00000000
16 [ 12.690927] Internal error: Oops: 17 [#1] SMP ARM
17 [ 12.695873] Modules linked in: btwilink bluetooth ti_vpfe dwc3(+) ov2659 videobuf2_core v4l2_common videodev ti_am335x_adc 6lowpan_iphc matrix_keypad panel_dpi kfifo_buf pixcir_i2c_ts media industrialio videobuf2_dma_contig c_can_platform videobuf2_memops dwc3_omap c_can can_dev
18 [ 12.721969] CPU: 0 PID: 1235 Comm: kworker/u3:0 Not tainted 3.14.25-02445-g9036ac6daed6 #128
19 [ 12.730937] Workqueue: hci0 hci_power_on [bluetooth]
20 [ 12.736165] task: ebd93b40 ti: ecd7c000 task.ti: ecd7c000
21 [ 12.741856] PC is at st_kim_ref+0x30/0x40
22 [ 12.746071] LR is at st_kim_ref+0x30/0x40
23 [ 12.750289] pc : [<c03caf58>] lr : [<c03caf58>] psr: a0000013
24 [ 12.750289] sp : ecd7de08 ip : ecd7de08 fp : ecd7de1c
25 [ 12.762365] r10: bf1e710c r9 : bf1e70ec r8 : bf1e7964
26 [ 12.767858] r7 : ebd2fd50 r6 : bf1e7964 r5 : 00000000 r4 : ecd7de24
27 [ 12.774723] r3 : c0957208 r2 : 00000000 r1 : c0957208 r0 : 00000000
28 [ 12.781589] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
29 [ 12.789274] Control: 10c5387d Table: abde4059 DAC: 00000015
30 [ 12.795315] Process kworker/u3:0 (pid: 1235, stack limit = 0xecd7c248)
32 Signed-off-by: Sekhar Nori <nsekhar@ti.com>
33 Signed-off-by: Gigi Joseph <gigi.joseph@ti.com>
34 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
35 ---
36 drivers/misc/ti-st/st_kim.c | 12 ++++++++----
37 1 file changed, 8 insertions(+), 4 deletions(-)
39 diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
40 index b0cddef..e37fd5f 100644
41 --- a/drivers/misc/ti-st/st_kim.c
42 +++ b/drivers/misc/ti-st/st_kim.c
43 @@ -691,12 +691,16 @@ void st_kim_ref(struct st_data_s **core_data, int id)
44 struct kim_data_s *kim_gdata;
45 /* get kim_gdata reference from platform device */
46 pdev = st_get_plat_device(id);
47 - if (!pdev) {
48 - *core_data = NULL;
49 - return;
50 - }
51 + if (!pdev)
52 + goto err;
53 kim_gdata = dev_get_drvdata(&pdev->dev);
54 + if (!kim_gdata)
55 + goto err;
56 +
57 *core_data = kim_gdata->core_data;
58 + return;
59 +err:
60 + *core_data = NULL;
61 }
63 static int kim_version_open(struct inode *i, struct file *f)
64 --
65 1.7.9.5