[PATCH v2 5/7] driver-core: generalize freeing driver private member
From: Luis R. Rodriguez
Date: Fri Oct 03 2014 - 20:15:04 EST
From: "Luis R. Rodriguez" <mcgrof@xxxxxxxx>
This will be used later.
Cc: Tejun Heo <tj@xxxxxxxxxx>
Cc: Arjan van de Ven <arjan@xxxxxxxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxx>
---
drivers/base/bus.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 83e910a..a5f41e4 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -657,6 +657,15 @@ static ssize_t uevent_store(struct device_driver *drv, const char *buf,
}
static DRIVER_ATTR_WO(uevent);
+static void remove_driver_private(struct device_driver *drv)
+{
+ struct driver_private *priv = drv->p;
+
+ kobject_put(&priv->kobj);
+ kfree(priv);
+ drv->p = NULL;
+}
+
/**
* bus_add_driver - Add a driver to the bus.
* @drv: driver.
@@ -719,9 +728,7 @@ int bus_add_driver(struct device_driver *drv)
return 0;
out_unregister:
- kobject_put(&priv->kobj);
- kfree(drv->p);
- drv->p = NULL;
+ remove_driver_private(drv);
out_put_bus:
bus_put(bus);
return error;
--
2.1.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/