[lkml]   [2013]   [Jan]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] drivers: avoid use after free of a pinctrl context pointer
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 <>
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:
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)
dev->driver = NULL;
+ dev->pins = NULL;
dev_set_drvdata(dev, NULL);
if (dev->bus)

 \ /
  Last update: 2013-01-16 18:21    [W:0.034 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site