From aa75936544fafc830ac3cc03458b771f3048a50f Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Mon, 28 Aug 2017 19:11:15 +0200 Subject: [PATCH] usb: core: usbport: fix "BUG: key not in .data" when lockdep is enabled This patch fixes a splat that happens if CONFIG_DEBUG_LOCK_ALLOC is enabled and the ledtrig_usbport is loaded. (on a device that has some usb ports). [ 60.695479] BUG: key c53f8420 not in .data! [ 60.695521] ------------[ cut here ]------------ [ 60.698542] WARNING: CPU: 1 PID: 854 at kernel/locking/lockdep.c:3134 __kernfs_create_file+0x5c/0xc0 [ 60.703355] DEBUG_LOCKS_WARN_ON(1) [ 60.712534] Modules linked in: [ 60.944078] CPU: 1 PID: 854 Comm: S96led Not tainted 4.9.44 #0 [ 60.944329] Hardware name: Generic DT based system [ 60.950106] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 60.954878] [] (show_stack) from [] (dump_stack+0x7c/0x9c) [ 60.962772] [] (dump_stack) from [] (__warn+0xbc/0xec) [ 60.969799] [] (__warn) from [] (warn_slowpath_fmt+0x34/0x44) [ 60.976656] [] (warn_slowpath_fmt) [ 60.984210] [] (__kernfs_create_file) [ 60.992712] [] (sysfs_add_file_mode_ns) [ 61.002090] [] (sysfs_add_file) from [ 61.010619] [] (sysfs_add_file_to_group) [ 61.019263] [] (usbport_trig_add_usb_dev_ports [ledtrig_usbport]) [ 61.031002] [] (bus_for_each_dev) [ 61.042106] [] (usb_for_each_dev) [ 61.050375] [] (usbport_trig_activate [ledtrig_usbport]) [ 61.060685] [] (led_trigger_set) from [] [...] Signed-off-by: Christian Lamparter Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/ledtrig-usbport.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/core/ledtrig-usbport.c b/drivers/usb/core/ledtrig-usbport.c index 5e26588..1af8779 100644 --- a/drivers/usb/core/ledtrig-usbport.c +++ b/drivers/usb/core/ledtrig-usbport.c @@ -205,6 +205,7 @@ static int usbport_trig_add_port(struct usbport_trig_data *usbport_data, } snprintf(port->port_name, len, "%s-port%d", hub_name, portnum); + sysfs_attr_init(&port->attr.attr); port->attr.attr.name = port->port_name; port->attr.attr.mode = S_IRUSR | S_IWUSR; port->attr.show = usbport_trig_port_show; -- 2.7.4