Skip to content

Commit 15fec50

Browse files
committed
ev3_ports_in: fix trying to cancel uninitalized work
__flush_work() has been modifed to warn when called with an unintialed work struct. So, we need to protect against calling it when we have not initalized data->work. Fixes the following warning: [43297.092951] ------------[ cut here ]------------ [43297.098131] WARNING: CPU: 0 PID: 667 at /home/david/work/ev3dev-dpkg/ev3dev-kpkg/ev3-kernel/kernel/workqueue.c:2911 __flush_work+0x74/0x218 [43297.113331] Modules linked in: iptable_nat nf_nat_ipv4 nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c usb_f_rndis usb_f_ecm u_ether ev3_uart_sensor_ld ev3_uart_sensor rtl8150 hci_uart nxt_i2c_sensor servo_motor_class uinput libcomposite sunrpc ip_tables x_tables [43297.140457] CPU: 0 PID: 667 Comm: bash Not tainted 4.19.85-ev3dev-3-beta1-ev3+ #502 [43297.148915] Hardware name: LEGO MINDSTORMS EV3 [43297.156605] Backtrace: [43297.158370] [<c000d7ec>] (dump_backtrace) from [<c000daa8>] (show_stack+0x18/0x1c) [43297.166133] r7:00000009 r6:00000000 r5:c06b2c50 r4:00000000 [43297.181258] [<c000da90>] (show_stack) from [<c0558bd8>] (dump_stack+0x20/0x28) [43297.198079] [<c0558bb8>] (dump_stack) from [<c0018ffc>] (__warn+0xe8/0x104) [43297.224279] [<c0018f14>] (__warn) from [<c0019134>] (warn_slowpath_null+0x44/0x50) [43297.235383] r9:c002e9d8 r8:ffffe000 r7:00000000 r6:c002e208 r5:00000b5f r4:c06b2c50 [43297.249291] [<c00190f0>] (warn_slowpath_null) from [<c002e208>] (__flush_work+0x74/0x218) [43297.258805] r6:c3b8d22c r5:c0771008 r4:00000000 [43297.263365] [<c002e194>] (__flush_work) from [<c0030b80>] (__cancel_work_timer+0x128/0x1c4) [43297.276470] r8:ffffe000 r7:00000000 r6:c0771008 r5:c3b8d22c r4:ffffffe0 [43297.295256] [<c0030a58>] (__cancel_work_timer) from [<c0030c30>] (cancel_work_sync+0x14/0x18) [43297.313222] r9:00000051 r8:00000033 r7:00000008 r6:c3b8d240 r5:c3b8d22c r4:c3b8d020 [43297.329277] [<c0030c1c>] (cancel_work_sync) from [<c03e72b8>] (ev3_input_port_set_mode+0x30/0x1b8) [43297.358626] [<c03e7288>] (ev3_input_port_set_mode) from [<c03e4f10>] (mode_store+0x70/0xa4) [43297.372683] r7:00000004 r6:00000008 r5:00000008 r4:c3b8d090 [43297.383258] [<c03e4ea0>] (mode_store) from [<c02e7ce8>] (dev_attr_store+0x20/0x2c) [43297.399219] r9:00000051 r8:c3959bb0 r7:c3159f60 r6:c3959ba0 r5:c30dc900 r4:c03e4ea0 [43297.412968] [<c02e7cc8>] (dev_attr_store) from [<c014b318>] (sysfs_kf_write+0x40/0x4c) [43297.438883] r5:c30dc900 r4:c02e7cc8 [43297.453229] [<c014b2d8>] (sysfs_kf_write) from [<c014a638>] (kernfs_fop_write+0x138/0x1a8) [43297.483787] r5:c30dc900 r4:00000004 [43297.490029] [<c014a500>] (kernfs_fop_write) from [<c00da6dc>] (__vfs_write+0x40/0x164) [43297.503387] r9:00000004 r8:c3159f60 r7:c0771008 r6:00125a08 r5:c33ad6e0 r4:c014a500 [43297.511534] [<c00da69c>] (__vfs_write) from [<c00da9c0>] (vfs_write+0xc4/0x150) [43297.524075] r9:00000004 r8:00000000 r7:c3159f60 r6:00125a08 r5:00000004 r4:c33ad6e0 [43297.537895] [<c00da8fc>] (vfs_write) from [<c00dabf0>] (ksys_write+0x64/0xc0) [43297.561845] r9:00000004 r8:00125a08 r7:c0771008 r6:c33ad6e0 r5:00125a08 r4:c33ad6e0 [43297.588358] [<c00dab8c>] (ksys_write) from [<c00dac5c>] (sys_write+0x10/0x14) [43297.608179] r9:c3158000 r8:c00091e4 r7:00000004 r6:b6edbd50 r5:00125a08 r4:00000004 [43297.621605] [<c00dac4c>] (sys_write) from [<c0009000>] (ret_fast_syscall+0x0/0x50) [43297.631751] Exception stack(0xc3159fa8 to 0xc3159ff0) [43297.641204] 9fa0: 00000004 00125a08 00000001 00125a08 00000004 00000000 [43297.659828] 9fc0: 00000004 00125a08 b6edbd50 00000004 00000004 00000004 00000000 00118fd8 [43297.670180] 9fe0: 00000000 bee8384c b6e0060c b6e5c04c [43297.680830] ---[ end trace 8a3544246704cce4 ]---
1 parent 3f7760e commit 15fec50

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

ev3/ev3_ports_in.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,8 @@ static int ev3_input_port_set_mode(void *context, u8 mode)
929929
*/
930930

931931
hrtimer_cancel(&data->timer);
932-
cancel_work_sync(&data->work);
932+
if (data->work.func)
933+
cancel_work_sync(&data->work);
933934

934935
switch (data->port.mode) {
935936
case EV3_INPUT_PORT_MODE_OTHER_I2C:
@@ -1259,7 +1260,8 @@ static int ev3_input_port_remove(struct platform_device *pdev)
12591260

12601261
hrtimer_cancel(&data->timer);
12611262
cancel_work_sync(&data->change_uevent_work);
1262-
cancel_work_sync(&data->work);
1263+
if (data->work.func)
1264+
cancel_work_sync(&data->work);
12631265
if (data->port.mode == EV3_INPUT_PORT_MODE_OTHER_UART)
12641266
ev3_input_port_disable_uart(data);
12651267
if (data->port.mode == EV3_INPUT_PORT_MODE_RAW)

0 commit comments

Comments
 (0)