From: Tiejun Chen <[email protected]> When perform kexec or reboot, kernel may panic as follows:
Oops: Kernel access of bad area, sig: 11 [#1] PREEMPT SMP NR_CPUS=8 LTT NESTING LEVEL : 0 B4 QDS Modules linked in: NIP: c000000000603680 LR: c0000000006037d8 CTR: c000000000578c70 REGS: c0000000f83c3470 TRAP: 0300 Tainted: G W (3.4.43-rt56-WR5.0.1.0_preempt-rt) MSR: 0000000080029000 <CE,EE,ME> CR: 44024022 XER: 00000000 SOFTE: 1 DEAR: 0000000000000038, ESR: 0000000000000000 TASK = c0000000f999c840[1620] 'kexec' THREAD: c0000000f83c0000 CPU: 7 GPR00: 0000000000000005 c0000000f83c36f0 c00000000116e800 c0000000f999e000 GPR04: c0000000f83c3760 0000000000000000 0000000000000001 0000000000000001 GPR08: c0000000079e30d0 0000000000000000 0000000006e60000 8000000000000000 GPR12: 0000000024024082 c00000000ffffc00 0000000010029f88 0000000000000001 GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000002 GPR20: 0000000000000002 00000000100327b8 ffffffffffffffff 0000000010013400 GPR24: 0000000000000002 00000fffeb57a4d8 c0000000011ba810 c000000000ffd038 GPR28: c0000000f9959600 0000000000000018 c0000000010bd6c0 c0000000f995d800 NIP [c000000000603680] .FM_PORT_Free+0x90/0x300 LR [c0000000006037d8] .FM_PORT_Free+0x1e8/0x300 Call Trace: [c0000000f83c36f0] [c0000000006037d8] .FM_PORT_Free+0x1e8/0x300 (unreliable) [c0000000f83c3790] [c00000000061ad64] .FmHcFree+0x74/0xa0 [c0000000f83c3820] [c0000000005d742c] .FM_PCD_Free+0xfc/0x2e0 [c0000000f83c38c0] [c000000000630f6c] .FreeFmPcdDev+0x2c/0x80 [c0000000f83c3940] [c00000000062b54c] .FreeFmDev.part.3+0x2c/0x190 [c0000000f83c39c0] [c000000000922288] .fm_remove+0xa4/0x198 [c0000000f83c3a50] [c000000000518d60] .platform_drv_shutdown+0x40/0x60 [c0000000f83c3ad0] [c0000000005137b8] .device_shutdown+0x58/0x150 [c0000000f83c3b60] [c000000000081314] .kernel_restart_prepare+0x54/0x70 [c0000000f83c3be0] [c0000000000da798] .kernel_kexec+0x138/0x190 [c0000000f83c3c90] [c0000000000816a4] .SyS_reboot+0x284/0x2d0 [c0000000f83c3e30] [c000000000000720] syscall_exit+0x0/0x60 Instruction dump: 41de0014 4804f89d 60000000 38000000 f81f0270 893f0062 38810070 801f003c e87f0020 99210070 39200000 90010074 <88090038> 98010078 4bf75fa9 60000000 Segmentation fault This is introduced while accessing that invalid p_FmPort->p_FmPortDriverParam by FM_PORT_Free(). So we should check if p_FmPort->p_FmPortDriverParam is already freed somewhere, and especially inside FM_PORT_Free(), we also need to push FmPortDriverParamFree(p_FmPort) downwards to guarantee this. Signed-off-by: Tiejun Chen <[email protected]> Signed-off-by: Bin Jiang <[email protected]> Signed-off-by: Meng Li <[email protected]> --- .../freescale/sdk_fman/Peripherals/FM/Port/fm_port.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c index a0680855dcdf..8ab18f48e1a2 100644 --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c @@ -2788,13 +2788,11 @@ t_Error FM_PORT_Free(t_Handle h_FmPort) if (p_FmPort->imEn) FmPortImFree(p_FmPort); - FmPortDriverParamFree(p_FmPort); - memset(&fmParams, 0, sizeof(fmParams)); fmParams.hardwarePortId = p_FmPort->hardwarePortId; fmParams.portType = (e_FmPortType)p_FmPort->portType; - fmParams.deqPipelineDepth = - p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth; + if (p_FmPort->p_FmPortDriverParam) + fmParams.deqPipelineDepth = p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth; FmFreePortParams(p_FmPort->h_Fm, &fmParams); @@ -2807,6 +2805,8 @@ t_Error FM_PORT_Free(t_Handle h_FmPort) FM_MURAM_FreeMem(p_FmPort->h_FmMuram, p_FmPort->p_ParamsPage); #endif /* (DPAA_VERSION >= 11) */ + FmPortDriverParamFree(p_FmPort); + if (p_FmPort->h_Spinlock) XX_FreeSpinlock(p_FmPort->h_Spinlock); -- 2.35.3
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#11268): https://lists.yoctoproject.org/g/linux-yocto/message/11268 Mute This Topic: https://lists.yoctoproject.org/mt/90772517/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
