Skip to content

Commit

Permalink
serial: core: Fix kmemleak issue for serial core device remove
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Tony Lindgren <[email protected]>
Tested-by: Tomi Valkeinen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
tmlind authored and gregkh committed Aug 4, 2023
1 parent 238500e commit 6be1a8d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/tty/serial/serial_base_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void serial_base_ctrl_device_remove(struct serial_ctrl_device *ctrl_dev)
return;

device_del(&ctrl_dev->dev);
put_device(&ctrl_dev->dev);
}

struct serial_ctrl_device *serial_base_ctrl_add(struct uart_port *port,
Expand Down Expand Up @@ -174,6 +175,7 @@ void serial_base_port_device_remove(struct serial_port_device *port_dev)
return;

device_del(&port_dev->dev);
put_device(&port_dev->dev);
}

static int serial_base_init(void)
Expand Down

0 comments on commit 6be1a8d

Please sign in to comment.