For S32G, the num_custom_params for pinctrl desc struct should be 0,
because there is no driver-specific custom parameters at all.

But if this member is not set to 0 explicitly, the value may be a
unexpected random value, which may cause the following boot failure:

 ------------[ cut here ]------------
 WARNING: CPU: 1 PID: 1 at /mm/page_alloc.c:4403 __alloc_pages+0x2ac/0x458
 Modules linked in:
 CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.6.36-yocto-standard #1
 Hardware name: NXP S32G3 Reference Design Board (S32G-VNP-RDB3) (DT)
 pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
 pc : __alloc_pages+0x2ac/0x458
 lr : __kmalloc_large_node+0x8c/0x190
 sp : ffffffc0834fb770
 x29: ffffffc0834fb7a0 x28: ffffffc08177e000 x27: ffffffc08177f2f0
 x26: ffffffc08177f2e8 x25: ffffffc0834fb8ec x24: ffffffc0834fb8f0
 x23: ffffff8804f3b400 x22: 0000000000040dc0 x21: 0000000000000000
 x20: 0000000000000016 x19: 0000000000000000 x18: ffffffffffffffff
 x17: ffffffc080bf9a10 x16: ffffffc080a25008 x15: ffffffc080a1fbcc
 x14: ffffffffffffffff x13: 0000000000000ea2 x12: ffffffc082aa6c60
 x11: 00000000000000f9 x10: 00000000000000f9 x9 : ffffffc0802f12fc
 x8 : ffffffc0834fb758 x7 : 0000000000000000 x6 : 0000000000000001
 x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
 x2 : ffffff8800c90040 x1 : 0000000000000001 x0 : ffffffc08230bdf4
 Call trace:
  __alloc_pages+0x2ac/0x458
  __kmalloc_large_node+0x8c/0x190
  __kmalloc+0x9c/0xf8
  pinconf_generic_parse_dt_config+0x70/0x1c8
  s32_dt_node_to_map+0x11c/0x258
  pinctrl_dt_to_map+0x22c/0x360
  create_pinctrl+0x68/0x258
  pinctrl_enable+0x28/0x160
  devm_pinctrl_register+0x7c/0xd8
  s32_pinctrl_probe+0x150/0x208
  platform_probe+0x70/0xd8
  really_probe+0x184/0x390
  __driver_probe_device+0xb0/0x168
  driver_probe_device+0x44/0x120
  __driver_attach+0xb0/0x1d0
  bus_for_each_dev+0x84/0xf0
  driver_attach+0x2c/0x40
  bus_add_driver+0x104/0x230
  driver_register+0x64/0x138
  __platform_driver_register+0x30/0x48
  s32cc_pinctrl_driver_init+0x24/0x38
  do_one_initcall+0xbc/0x398
  do_initcalls+0x13c/0x258
  kernel_init_freeable+0x1a0/0x280
  kernel_init+0x30/0x1f8
  ret_from_fork+0x10/0x20
 irq event stamp: 1878486
 hardirqs last  enabled at (1878485): [<ffffffc0812e62e8>] 
_raw_spin_unlock_irqrestore+0x70/0xb0
 hardirqs last disabled at (1878486): [<ffffffc0812d6abc>] el1_dbg+0x24/0x90
 softirqs last  enabled at (1861648): [<ffffffc0800553cc>] 
handle_softirqs+0x4f4/0x520
 softirqs last disabled at (1861643): [<ffffffc0800101f4>] 
__do_softirq+0x1c/0x28
 ---[ end trace 0000000000000000 ]---
 s32cc-siul2-pinctrl 4009c240.siul2-pinctrl: 
/soc/siul2@4009c000/siul2-pinctrl@4009c240/jtag_pins/jtag_grp0: could not parse 
node property
 s32cc-siul2-pinctrl 4009c240.siul2-pinctrl: error claiming hogs: -12
 s32cc-siul2-pinctrl 4009c240.siul2-pinctrl: could not claim hogs: -12
 s32cc-siul2-pinctrl 4009c240.siul2-pinctrl: error -ENOMEM: could not register 
s32 pinctrl driver
 s32cc-siul2-pinctrl: probe of 4009c240.siul2-pinctrl failed with error -12

So change to use devm_kzalloc() to alloc pinctrl_desc struct, then the
related members are all initialised to 0, then the above issue can be fixed.

Signed-off-by: Zhantao Tang <zhantao.t...@windriver.com>
---
 drivers/pinctrl/nxp/pinctrl-s32cc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c 
b/drivers/pinctrl/nxp/pinctrl-s32cc.c
index d00382b671b4..0c4e1cf838a2 100644
--- a/drivers/pinctrl/nxp/pinctrl-s32cc.c
+++ b/drivers/pinctrl/nxp/pinctrl-s32cc.c
@@ -962,7 +962,7 @@ static int s32_pinctrl_probe(struct platform_device *pdev)
        spin_lock_init(&ipctl->gpio_configs_lock);
 
        s32_pinctrl_desc =
-               devm_kmalloc(&pdev->dev, sizeof(*s32_pinctrl_desc), GFP_KERNEL);
+               devm_kzalloc(&pdev->dev, sizeof(*s32_pinctrl_desc), GFP_KERNEL);
        if (!s32_pinctrl_desc)
                return -ENOMEM;
 
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#14119): 
https://lists.yoctoproject.org/g/linux-yocto/message/14119
Mute This Topic: https://lists.yoctoproject.org/mt/107116487/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to