From 0ae68bc5077c571b0b6c9de439e66a61b83b3851 Mon Sep 17 00:00:00 2001 From: Julien CHAUVEAU Date: Tue, 14 Oct 2014 08:42:47 +0200 Subject: [PATCH] pinctrl: rockchip: fix NULL pointer exception This patch is more tolerant to the typo errors on the rockchip,pins property (eg. rockchip-pins, rockchip-pin...) and provides a nice error message instead of raising a NULL pointer exception. Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 5 [#1] SMP ARM Modules linked in: CPU: 2 PID: 1 Comm: swapper/0 Not tainted 3.17.0-rc6-next-20140925+ #118 task: ee0379c0 ti: ee05c000 task.ti: ee05c000 PC is at rockchip_pinctrl_probe+0xbd0/0xe3c LR is at devres_add+0x3c/0x40 pc : [] lr : [] psr: 80000113 sp : ee05dc80 ip : ee05dc48 fp : ee05dcfc r10: 00000000 r9 : 00000000 r8 : ee7ed334 r7 : 0000002f r6 : ee197f00 r5 : ee7ed290 r4 : ee124210 r3 : 00000004 r2 : c0bc4250 r1 : 40000113 r0 : ee1ac990 Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 10c5387d Table: 6000404a DAC: 00000015 Process swapper/0 (pid: 1, stack limit = 0xee05c240) Stack: (0xee05dc80 to 0xee05e000) dc80: ee7ed474 00001c00 00000000 00000001 ee11cb78 00000000 00000001 00000017 dca0: ee196f18 ee12f400 ee7e822c ee12f410 00000000 00000004 200800ff ee7e8c18 dcc0: 00000200 00000000 00000000 00000000 ee12f418 ee12f410 ffffffed c0bc3994 dce0: c0bdcc88 c0c2766c 00000000 00000000 ee05dd1c ee05dd00 c0256f80 c0201010 dd00: c0256f30 ee12f410 c0bc3994 00000000 ee05dd4c ee05dd20 c025555c c0256f3c dd20: ee05dd4c ee05dd30 c0bc3994 ee12f410 c0255770 00000000 00000000 00000000 dd40: ee05dd64 ee05dd50 c02557a0 c025542c 00000000 ee12f410 ee05dd8c ee05dd68 dd60: c0253a38 c025577c ee038770 ee124fb8 c0482a58 ee12f410 c0bca028 ee12f444 dd80: ee05ddac ee05dd90 c02553a8 c02539c4 00000001 ee12f410 c0bca028 ee12f410 dda0: ee05ddcc ee05ddb0 c0254918 c0255348 00000000 ee12f410 00000000 ee12f418 ddc0: ee05de04 ee05ddd0 c0252c48 c02548f4 ee05de14 ee05dde0 c0327e9c c0329ad4 dde0: ee12f400 ee7e827c 00000000 00000000 00000000 00000001 ee05de14 ee05de08 de00: c0327a64 c0252814 ee05de3c ee05de18 c03282d0 c0327a34 00000000 ee7e822c de20: 00000000 00000000 00000000 c04b9da4 ee05de9c ee05de40 c0328590 c0328268 de40: 00000001 ffffffff 00000000 00000000 ff0a0005 ffffffff ee05de84 ee05ded8 de60: ee05de9c ee05de70 c0326910 c01e24e8 ee05de9c ee7e822c ee7e099c c04b9da4 de80: 00000000 00000000 00000001 00000000 ee05decc ee05dea0 c0328800 c0328324 dea0: 00000001 c05f16b0 ee125340 c0bb7ba0 c0bb7ba0 c0be36c0 c05f16b0 0000009a dec0: ee05dedc ee05ded0 c05f16e8 c03287a0 ee05df5c ee05dee0 c0008ab0 c05f16bc dee0: c0113df0 c0113adc ee05df0c ee05def8 c0038400 c00383f4 ef7fccfb 00000000 df00: ee05df5c ee05df10 c0038730 c05ee600 c004db80 c0484378 00000000 c05ec86c df20: 00000003 00000003 0000009a c05ebecc 00000000 00000003 c06216dc c062d2e4 df40: c0be36c0 c0be36c0 0000009a 00000000 ee05df94 ee05df60 c05eee10 c000899c df60: 00000003 00000003 c05ee5f4 ee0379c0 00000000 c047d8a8 00000000 00000000 df80: 00000000 00000000 ee05dfac ee05df98 c047d8b8 c05eed00 ee05c000 00000000 dfa0: 00000000 ee05dfb0 c000e958 c047d8b4 00000000 00000000 00000000 00000000 dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 13048395 9f284081 Backtrace: [] (rockchip_pinctrl_probe) from [] (platform_drv_probe+0x50/0x9c) r10:00000000 r9:00000000 r8:c0c2766c r7:c0bdcc88 r6:c0bc3994 r5:ffffffed r4:ee12f410 [] (platform_drv_probe) from [] (driver_probe_device+0x13c/0x350) r6:00000000 r5:c0bc3994 r4:ee12f410 r3:c0256f30 [] (driver_probe_device) from [] (__device_attach+0x30/0x4c) r9:00000000 r8:00000000 r7:00000000 r6:c0255770 r5:ee12f410 r4:c0bc3994 [] (__device_attach) from [] (bus_for_each_drv+0x80/0x94) r5:ee12f410 r4:00000000 [] (bus_for_each_drv) from [] (device_attach+0x6c/0x90) r6:ee12f444 r5:c0bca028 r4:ee12f410 [] (device_attach) from [] (bus_probe_device+0x30/0xa0) r6:ee12f410 r5:c0bca028 r4:ee12f410 r3:00000001 [] (bus_probe_device) from [] (device_add+0x440/0x52c) r6:ee12f418 r5:00000000 r4:ee12f410 r3:00000000 [] (device_add) from [] (of_device_add+0x3c/0x40) r9:00000001 r8:00000000 r7:00000000 r6:00000000 r5:ee7e827c r4:ee12f400 [] (of_device_add) from [] (of_platform_device_create_pdata+0x74/0xa0) [] (of_platform_device_create_pdata) from [] (of_platform_bus_create+0x278/0x368) r8:c04b9da4 r7:00000000 r6:00000000 r5:00000000 r4:ee7e822c r3:00000000 [] (of_platform_bus_create) from [] (of_platform_populate+0x6c/0x98) r10:00000000 r9:00000001 r8:00000000 r7:00000000 r6:c04b9da4 r5:ee7e099c r4:ee7e822c [] (of_platform_populate) from [] (customize_machine+0x38/0x48) r9:0000009a r8:c05f16b0 r7:c0be36c0 r6:c0bb7ba0 r5:c0bb7ba0 r4:ee125340 [] (customize_machine) from [] (do_one_initcall+0x120/0x1d4) [] (do_one_initcall) from [] (kernel_init_freeable+0x11c/0x1e4) r10:00000000 r9:0000009a r8:c0be36c0 r7:c0be36c0 r6:c062d2e4 r5:c06216dc r4:00000003 [] (kernel_init_freeable) from [] (kernel_init+0x10/0xec) r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c047d8a8 r4:00000000 [] (kernel_init) from [] (ret_from_fork+0x14/0x3c) r4:00000000 r3:ee05c000 Code: e51b3048 e15a0003 aa000031 e5942014 (e5990000) ---[ end trace a350fda3a1974f25 ]--- --- drivers/pinctrl/pinctrl-rockchip.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 3c22dbebc80f20..7eb5dc32e9d080 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -1108,7 +1108,12 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np, * do sanity check and calculate pins number */ list = of_get_property(np, "rockchip,pins", &size); - /* we do not check return since it's safe node passed down */ + if (!list) { + dev_err(info->dev, "node %s should contain a valid rockchip,pins property\n", + np->name); + return -EINVAL; + } + size /= sizeof(*list); if (!size || size % 4) { dev_err(info->dev, "wrong pins number or pins and configs should be by 4\n");