Skip to content

Commit 131ee29

Browse files
xzz53intel-lab-lkp
authored andcommitted
phy: rockchip-inno-usb2: Fix otg port initialization
There are two issues in rockchip_usb2phy_otg_port_init(): (1) even if devm_extcon_register_notifier() returns error, the code proceeds to the next if statement and (2) if no extcon is defined in of_node, the return value of property_enabled() is reused as the return value of the whole function. If the return value of property_enable() is nonzero, (2) results in an unexpected probe failure and kernel panic in delayed work: Unable to handle kernel NULL pointer dereference at virtual address 00000000 Mem abort info: ESR = 0x0000000086000006 EC = 0x21: IABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 FSC = 0x06: level 2 translation fault user pgtable: 4k pages, 48-bit VAs, pgdp=00000000019dc000 [0000000000000000] pgd=080000000131a003, p4d=080000000131a003, pud=080000000 Internal error: Oops: 86000006 [#1] PREEMPT SMP Modules linked in: ipv6 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.0.0-rc5 torvalds#114 Hardware name: FriendlyElec NanoPi M4 (DT) pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : 0x0 lr : call_timer_fn.constprop.0+0x24/0x80 sp : ffff80000a40ba40 x29: ffff80000a40ba40 x28: 0000000000000000 x27: ffff80000a40baf0 x26: ffff800009e779c0 x25: ffff00007fb28070 x24: ffff00007fb28028 x23: ffff80000a40baf0 x22: 0000000000000000 x21: 0000000000000101 x20: ffff0000006ad880 x19: 0000000000000000 x18: 0000000000000006 x17: ffff8000761af000 x16: ffff80000800c000 x15: 0000000000004000 x14: ffff0000006ad880 x13: 000000000000030a x12: 0000000000000000 x11: ffff8000761af000 x10: ffff80000800bf40 x9 : ffff00007fb2d038 x8 : 0000000000000001 x7 : 0000000000000009 x6 : 0000000000000240 x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000200 x2 : 000000003fffffff x1 : 0000000000000000 x0 : ffff0000016c9710 Call trace: 0x0 __run_timers+0x220/0x264 run_timer_softirq+0x20/0x40 __do_softirq+0x10c/0x298 __irq_exit_rcu+0xec/0xf4 irq_exit_rcu+0x10/0x1c el1_interrupt+0x38/0x70 el1h_64_irq_handler+0x18/0x24 el1h_64_irq+0x64/0x68 cpuidle_enter_state+0x130/0x2fc cpuidle_enter+0x38/0x50 do_idle+0x22c/0x2c0 cpu_startup_entry+0x24/0x30 secondary_start_kernel+0x130/0x14c __secondary_switched+0xb0/0xb4 Code: bad PC value ---[ end trace 0000000000000000 ]--- Kernel panic - not syncing: Oops: Fatal exception in interrupt SMP: stopping secondary CPUs Kernel Offset: disabled CPU features: 0x4000,0820b021,00001086 Memory Limit: none ---[ end Kernel panic - not syncing: Oops: Fatal exception in interrupt ]--- Refactor the control flow to avoid both issues. Since the code below out: label does no cleanup, return error codes immediately instead of using gotos and return success at the end of the function. Cc: [email protected] Fixes: 8dc60f8 ("phy: rockchip-inno-usb2: Sync initial otg state") Signed-off-by: Mikhail Rudenko <[email protected]>
1 parent 128245e commit 131ee29

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/phy/rockchip/phy-rockchip-inno-usb2.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,8 +1144,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
11441144
rport->mode = of_usb_get_dr_mode_by_phy(child_np, -1);
11451145
if (rport->mode == USB_DR_MODE_HOST ||
11461146
rport->mode == USB_DR_MODE_UNKNOWN) {
1147-
ret = 0;
1148-
goto out;
1147+
return 0;
11491148
}
11501149

11511150
INIT_DELAYED_WORK(&rport->chg_work, rockchip_chg_detect_work);
@@ -1154,16 +1153,18 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
11541153
ret = rockchip_usb2phy_port_irq_init(rphy, rport, child_np);
11551154
if (ret) {
11561155
dev_err(rphy->dev, "failed to init irq for host port\n");
1157-
goto out;
1156+
return ret;
11581157
}
11591158

11601159
if (!IS_ERR(rphy->edev)) {
11611160
rport->event_nb.notifier_call = rockchip_otg_event;
11621161

11631162
ret = devm_extcon_register_notifier(rphy->dev, rphy->edev,
11641163
EXTCON_USB_HOST, &rport->event_nb);
1165-
if (ret)
1164+
if (ret) {
11661165
dev_err(rphy->dev, "register USB HOST notifier failed\n");
1166+
return ret;
1167+
}
11671168

11681169
if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
11691170
/* do initial sync of usb state */
@@ -1172,8 +1173,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
11721173
}
11731174
}
11741175

1175-
out:
1176-
return ret;
1176+
return 0;
11771177
}
11781178

11791179
static int rockchip_usb2phy_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)