* [PATCH] drivers: avoid use after free of a pinctrl context pointer
@ 2013-01-16 16:22 Guennadi Liakhovetski
2013-01-18 1:37 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Guennadi Liakhovetski @ 2013-01-16 16:22 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel
During probing, pinctrl context is allocated and assigned to the struct
device::pins pointer. If probing fails or if the driver is later unbound
and re-probed again, the memory is freed, but the pointer is not cleared.
On a repeated probing attempt a non-NULL pointer indicates an already
allocated context, which then gets used. To avoid this the pointer must
be cleared.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
drivers/base/dd.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 65631015..e5c71b5 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -302,6 +302,7 @@ probe_failed:
devres_release_all(dev);
driver_sysfs_remove(dev);
dev->driver = NULL;
+ dev->pins = NULL;
dev_set_drvdata(dev, NULL);
if (ret == -EPROBE_DEFER) {
@@ -505,6 +506,7 @@ static void __device_release_driver(struct device *dev)
drv->remove(dev);
devres_release_all(dev);
dev->driver = NULL;
+ dev->pins = NULL;
dev_set_drvdata(dev, NULL);
klist_remove(&dev->p->knode_driver);
if (dev->bus)
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drivers: avoid use after free of a pinctrl context pointer
2013-01-16 16:22 [PATCH] drivers: avoid use after free of a pinctrl context pointer Guennadi Liakhovetski
@ 2013-01-18 1:37 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2013-01-18 1:37 UTC (permalink / raw)
To: Guennadi Liakhovetski; +Cc: linux-kernel
On Wed, Jan 16, 2013 at 05:22:34PM +0100, Guennadi Liakhovetski wrote:
> During probing, pinctrl context is allocated and assigned to the struct
> device::pins pointer. If probing fails or if the driver is later unbound
> and re-probed again, the memory is freed, but the pointer is not cleared.
> On a repeated probing attempt a non-NULL pointer indicates an already
> allocated context, which then gets used. To avoid this the pointer must
> be cleared.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
> drivers/base/dd.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
This can't go through my tree, as it breaks the build. Please send it
to whereever the pinctrl code is coming from.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-18 1:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-16 16:22 [PATCH] drivers: avoid use after free of a pinctrl context pointer Guennadi Liakhovetski
2013-01-18 1:37 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).