lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1434394615-3754-9-git-send-email-tomas.winkler@intel.com>
Date:	Mon, 15 Jun 2015 21:56:48 +0300
From:	Tomas Winkler <tomas.winkler@...el.com>
To:	gregkh@...uxfoundation.org
Cc:	arnd@...db.de, linux-kernel@...r.kernel.org,
	Tomas Winkler <tomas.winkler@...el.com>
Subject: [char-misc-next 08/15 V2] mei: bus: revamp probe and remove functions

Instead of generating device id on the fly during probing we
find the matching id entry on the device id table.
Get bus the module reference counter so it cannot
be unloaded after the driver has bounded to the client
device

Signed-off-by: Tomas Winkler <tomas.winkler@...el.com>
---
V2: Resend
 drivers/misc/mei/bus.c | 41 ++++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 7a40486d1c4f..88cca46bddcb 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -445,30 +445,49 @@ static int mei_cl_device_match(struct device *dev, struct device_driver *drv)
 	return 0;
 }
 
+/**
+ * mei_cl_device_probe - bus probe function
+ *
+ * @dev: device
+ *
+ * Return:  0 on success; < 0 otherwise
+ */
 static int mei_cl_device_probe(struct device *dev)
 {
-	struct mei_cl_device *cldev = to_mei_cl_device(dev);
+	struct mei_cl_device *cldev;
 	struct mei_cl_driver *cldrv;
-	struct mei_cl_device_id id;
+	const struct mei_cl_device_id *id;
+
+	cldev = to_mei_cl_device(dev);
+	cldrv = to_mei_cl_driver(dev->driver);
 
 	if (!cldev)
 		return 0;
 
-	cldrv = to_mei_cl_driver(dev->driver);
 	if (!cldrv || !cldrv->probe)
 		return -ENODEV;
 
-	dev_dbg(dev, "Device probe\n");
+	id = mei_cl_device_find(cldev, cldrv);
+	if (!id)
+		return -ENODEV;
 
-	strlcpy(id.name, cldev->name, sizeof(id.name));
+	__module_get(THIS_MODULE);
 
-	return cldrv->probe(cldev, &id);
+	return cldrv->probe(cldev, id);
 }
 
+/**
+ * mei_cl_device_remove - remove device from the bus
+ *
+ * @dev: device
+ *
+ * Return:  0 on success; < 0 otherwise
+ */
 static int mei_cl_device_remove(struct device *dev)
 {
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
 	struct mei_cl_driver *cldrv;
+	int ret = 0;
 
 	if (!cldev || !dev->driver)
 		return 0;
@@ -479,13 +498,13 @@ static int mei_cl_device_remove(struct device *dev)
 	}
 
 	cldrv = to_mei_cl_driver(dev->driver);
-	if (!cldrv->remove) {
-		dev->driver = NULL;
+	if (cldrv->remove)
+		ret = cldrv->remove(cldev);
 
-		return 0;
-	}
+	module_put(THIS_MODULE);
+	dev->driver = NULL;
+	return ret;
 
-	return cldrv->remove(cldev);
 }
 
 static ssize_t name_show(struct device *dev, struct device_attribute *a,
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ