lkml.org 
[lkml]   [2018]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 04/18] staging: gasket: device registration error and unregister fixups
Date
From: Todd Poynor <toddpoynor@google.com>

Remove device registration on class creation fail.

Hold mutex around device removal updates for proper ordering of
updates.

Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
---
drivers/staging/gasket/gasket_core.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
index 45914ebc8f44..3bdf7d36b397 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -342,7 +342,8 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc)
if (IS_ERR_OR_NULL(internal->class)) {
gasket_nodev_error("Cannot register %s class [ret=%ld]",
driver_desc->name, PTR_ERR(internal->class));
- return PTR_ERR(internal->class);
+ ret = PTR_ERR(internal->class);
+ goto fail0;
}

/*
@@ -376,7 +377,10 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc)
fail1:
class_destroy(internal->class);

+fail0:
+ mutex_lock(&g_mutex);
g_descs[desc_idx].driver_desc = NULL;
+ mutex_unlock(&g_mutex);
return ret;
}
EXPORT_SYMBOL(gasket_register_device);
@@ -413,7 +417,9 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc)
class_destroy(internal_desc->class);

/* Finally, effectively "remove" the driver. */
+ mutex_lock(&g_mutex);
g_descs[desc_idx].driver_desc = NULL;
+ mutex_unlock(&g_mutex);

gasket_nodev_info("removed %s driver", driver_desc->name);
}
--
2.18.0.203.gfac676dfb9-goog
\
 
 \ /
  Last update: 2018-07-15 22:07    [W:0.203 / U:1.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site