[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170326145023.GO7909@n2100.armlinux.org.uk>
Date: Sun, 26 Mar 2017 15:50:24 +0100
From: Russell King - ARM Linux <linux@...linux.org.uk>
To: Leo Yan <leo.yan@...aro.org>
Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>,
Alessandro Zummo <a.zummo@...ertech.it>,
Alexandre Belloni <alexandre.belloni@...e-electrons.com>,
Linus Walleij <linus.walleij@...aro.org>,
Baptiste Reynal <b.reynal@...tualopensystems.com>,
Alex Williamson <alex.williamson@...hat.com>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org, rtc-linux@...glegroups.com,
linux-arm-kernel@...ts.infradead.org, kvm@...r.kernel.org,
alsa-devel@...a-project.org
Subject: Re: [PATCH 1/5] Input: ambakmi - Convert to use devm_*()
On Sun, Mar 26, 2017 at 10:41:50PM +0800, Leo Yan wrote:
> Convert driver to use devm_*() APIs so rely on driver model core layer
> to manage resources. This eliminates error path boilerplate and makes
> code neat.
>
> This patch also fixes the memory leakage for 'kmi->io' when remove
> module.
No, it is not leaked, in fact, your patch introduces a use-after-free
bug.
kmi->io is of type "struct serio", and this structure has an embedded
"struct device". The lifetime of any structure containing a "struct
device" is controlled by the lifetime of the struct device.
Once serio_register_port() has been called on it, it is up to the
serio layer to free this structure.
Therefore, your patch creates a bug, and so it gets a NAK. There is no
resource leakage here.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
Powered by blists - more mailing lists