Commit 928e964f authored by Antonino A. Daplas's avatar Antonino A. Daplas Committed by Linus Torvalds

[PATCH] vt: Honor the return value of device_create_file

Check the return value of device_create_file().  If return is 'fail', remove
attributes by calling device_remove_file().
Signed-off-by: default avatarAntonino Daplas <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 212f2639
...@@ -106,7 +106,8 @@ ...@@ -106,7 +106,8 @@
#define MAX_NR_CON_DRIVER 16 #define MAX_NR_CON_DRIVER 16
#define CON_DRIVER_FLAG_MODULE 1 #define CON_DRIVER_FLAG_MODULE 1
#define CON_DRIVER_FLAG_INIT 2 #define CON_DRIVER_FLAG_INIT 2
#define CON_DRIVER_FLAG_ATTR 4
struct con_driver { struct con_driver {
const struct consw *con; const struct consw *con;
...@@ -3070,22 +3071,37 @@ static struct class_device_attribute class_device_attrs[] = { ...@@ -3070,22 +3071,37 @@ static struct class_device_attribute class_device_attrs[] = {
static int vtconsole_init_class_device(struct con_driver *con) static int vtconsole_init_class_device(struct con_driver *con)
{ {
int i; int i;
int error = 0;
con->flag |= CON_DRIVER_FLAG_ATTR;
class_set_devdata(con->class_dev, con); class_set_devdata(con->class_dev, con);
for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
class_device_create_file(con->class_dev, error = class_device_create_file(con->class_dev,
&class_device_attrs[i]); &class_device_attrs[i]);
if (error)
break;
}
return 0; if (error) {
while (--i >= 0)
class_device_remove_file(con->class_dev,
&class_device_attrs[i]);
con->flag &= ~CON_DRIVER_FLAG_ATTR;
}
return error;
} }
static void vtconsole_deinit_class_device(struct con_driver *con) static void vtconsole_deinit_class_device(struct con_driver *con)
{ {
int i; int i;
for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) if (con->flag & CON_DRIVER_FLAG_ATTR) {
class_device_remove_file(con->class_dev, for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
&class_device_attrs[i]); class_device_remove_file(con->class_dev,
&class_device_attrs[i]);
con->flag &= ~CON_DRIVER_FLAG_ATTR;
}
} }
/** /**
...@@ -3184,6 +3200,7 @@ int register_con_driver(const struct consw *csw, int first, int last) ...@@ -3184,6 +3200,7 @@ int register_con_driver(const struct consw *csw, int first, int last)
} else { } else {
vtconsole_init_class_device(con_driver); vtconsole_init_class_device(con_driver);
} }
err: err:
release_console_sem(); release_console_sem();
module_put(owner); module_put(owner);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment