[Devel] [PATCH RHEL7 COMMIT] ve/drivers: Do not forget to release mismatched device found
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jul 17 12:58:40 PDT 2015
The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.25
------>
commit 0dc34121a882509daf2207f8e0c3d4aa9d91914c
Author: Cyrill Gorcunov <gorcunov at virtuozzo.com>
Date: Fri Jul 17 23:58:39 2015 +0400
ve/drivers: Do not forget to release mismatched device found
Upon call of device_destroy_namespace we walk over namespace devices
looking for one which match on both device maj/min and VE itself,
but the thing is that if device belong to another VE we continue
iteration with never released get_device call.
Thus rework device_destroy_namespace (thanks to vdavydov@
for idea) -- pass __match_devt_ns matcher which would
test for namespace inside class_find_device itself.
https://jira.sw.ru/browse/PSBM-34777
Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
Reviewed-by: Vladimir Davydov <vdavydov at parallels.com>
CC: Andrey Vagin <avagin at virtuozzo.com>
CC: Konstantin Khorenko <khorenko at virtuozzo.com>
---
drivers/base/core.c | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6583bec..6167957 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1836,19 +1836,29 @@ void device_destroy(struct class *class, dev_t devt)
}
EXPORT_SYMBOL_GPL(device_destroy);
-void device_destroy_namespace(struct class *class, dev_t devt, void *ns)
+struct __match_devt_ns_arg {
+ dev_t devt;
+ void *ns;
+};
+
+static int __match_devt_ns(struct device *dev, const void *data)
{
- struct device *dev = NULL;
+ const struct __match_devt_ns_arg *arg = data;
- for (;;) {
- dev = class_find_device(class, dev, &devt, __match_devt);
- if (!dev)
- break;
- if (!class->namespace ||
- (class->namespace(dev) == ns))
- break;
- }
+ return dev->devt == arg->devt &&
+ (!dev->class->namespace ||
+ dev->class->namespace(dev) == arg->ns);
+}
+
+void device_destroy_namespace(struct class *class, dev_t devt, void *ns)
+{
+ struct __match_devt_ns_arg arg = {
+ .devt = devt,
+ .ns = ns,
+ };
+ struct device *dev;
+ dev = class_find_device(class, NULL, &arg, __match_devt_ns);
if (dev) {
put_device(dev);
device_unregister(dev);
More information about the Devel
mailing list