Skip to content

Commit 6be1a8d

Browse files
tmlindgregkh
authored andcommitted
serial: core: Fix kmemleak issue for serial core device remove
Kmemleak reports issues for serial8250 ports after the hardware specific driver takes over on boot as noted by Tomi. The kerneldoc for device_initialize() says we must call device_put() after calling device_initialize(). We are calling device_put() on the error path, but are missing it from the device remove path. This causes release() to never get called for the devices on remove. Let's add the missing put_device() calls for both serial ctrl and port devices. Fixes: 84a9582 ("serial: core: Start managing serial controllers to enable runtime PM") Reported-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Link: https://lore.kernel.org/r/20230804090909.51529-1-tony@atomide.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 238500e commit 6be1a8d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/tty/serial/serial_base_bus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ void serial_base_ctrl_device_remove(struct serial_ctrl_device *ctrl_dev)
9999
return;
100100

101101
device_del(&ctrl_dev->dev);
102+
put_device(&ctrl_dev->dev);
102103
}
103104

104105
struct serial_ctrl_device *serial_base_ctrl_add(struct uart_port *port,
@@ -174,6 +175,7 @@ void serial_base_port_device_remove(struct serial_port_device *port_dev)
174175
return;
175176

176177
device_del(&port_dev->dev);
178+
put_device(&port_dev->dev);
177179
}
178180

179181
static int serial_base_init(void)

0 commit comments

Comments
 (0)