From: Tony Lindgren <tony@atomide.com>
To: Jiri Slaby <jirislaby@kernel.org>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Andy Shevchenko" <andriy.shevchenko@intel.com>,
"Dhruva Gole" <d-gole@ti.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"John Ogness" <john.ogness@linutronix.de>,
"Johan Hovold" <johan@kernel.org>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
"Tomi Valkeinen" <tomi.valkeinen@ideasonboard.com>
Subject: Re: [PATCH] serial: core: Fix kmemleak issue for serial core device remove
Date: Fri, 4 Aug 2023 12:21:05 +0300 [thread overview]
Message-ID: <20230804092105.GI14799@atomide.com> (raw)
In-Reply-To: <959278d8-d76e-fda8-6d0d-64e284c0ba1b@kernel.org>
* Jiri Slaby <jirislaby@kernel.org> [230804 09:16]:
> On 04. 08. 23, 11:09, Tony Lindgren wrote:
> > 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: 84a9582fd203 ("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>
> > ---
> > drivers/tty/serial/serial_base_bus.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/tty/serial/serial_base_bus.c b/drivers/tty/serial/serial_base_bus.c
> > --- a/drivers/tty/serial/serial_base_bus.c
> > +++ b/drivers/tty/serial/serial_base_bus.c
> > @@ -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,
> > @@ -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);
>
> I didn't check the code, but device_unregister()?
I thought about that as it does the same, but since we're not calling
device_register() I felt it would be and unpaired call. No objections to
changing to use device_unregister() naturally if folks prefer that.
Regards,
Tony
next prev parent reply other threads:[~2023-08-04 9:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 9:09 [PATCH] serial: core: Fix kmemleak issue for serial core device remove Tony Lindgren
2023-08-04 9:16 ` Jiri Slaby
2023-08-04 9:21 ` Tony Lindgren [this message]
2023-08-04 13:11 ` Greg Kroah-Hartman
2023-08-04 9:46 ` Tomi Valkeinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230804092105.GI14799@atomide.com \
--to=tony@atomide.com \
--cc=andriy.shevchenko@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bigeasy@linutronix.de \
--cc=d-gole@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=johan@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox