diff options
author | Alexey Khoroshilov <khoroshilov@ispras.ru> | 2013-04-06 01:14:23 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-05 14:24:11 -0700 |
commit | 7e1389a9e622a421e85e8611c76bd9142bf4bff1 (patch) | |
tree | 784857c59a2b0f28d14f3364f31bb27a5ab9aca4 /drivers/staging/dgrp/dgrp_sysfs.c | |
parent | 70e90fb57f517dca891c737f8120389af71baee0 (diff) |
staging: dgrp: implement error handling in dgrp_create_class_sysfs_files()
There is no any error handling in dgrp_create_class_sysfs_files().
The patch adds code to check return values and propagate them to dgrp_init_module().
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/dgrp/dgrp_sysfs.c')
-rw-r--r-- | drivers/staging/dgrp/dgrp_sysfs.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/drivers/staging/dgrp/dgrp_sysfs.c b/drivers/staging/dgrp/dgrp_sysfs.c index be179adfb7c..7d1b36d1e75 100644 --- a/drivers/staging/dgrp/dgrp_sysfs.c +++ b/drivers/staging/dgrp/dgrp_sysfs.c @@ -85,30 +85,50 @@ static struct attribute_group dgrp_global_settings_attribute_group = { -void dgrp_create_class_sysfs_files(void) +int dgrp_create_class_sysfs_files(void) { int ret = 0; int max_majors = 1U << (32 - MINORBITS); dgrp_class = class_create(THIS_MODULE, "digi_realport"); + if (IS_ERR(dgrp_class)) + return PTR_ERR(dgrp_class); ret = class_create_file(dgrp_class, &class_attr_driver_version); + if (ret) + goto err_class; dgrp_class_global_settings_dev = device_create(dgrp_class, NULL, MKDEV(0, max_majors + 1), NULL, "driver_settings"); - + if (IS_ERR(dgrp_class_global_settings_dev)) { + ret = PTR_ERR(dgrp_class_global_settings_dev); + goto err_file; + } ret = sysfs_create_group(&dgrp_class_global_settings_dev->kobj, &dgrp_global_settings_attribute_group); if (ret) { pr_alert("%s: failed to create sysfs global settings device attributes.\n", __func__); - sysfs_remove_group(&dgrp_class_global_settings_dev->kobj, - &dgrp_global_settings_attribute_group); - return; + goto err_dev1; } dgrp_class_nodes_dev = device_create(dgrp_class, NULL, MKDEV(0, max_majors + 2), NULL, "nodes"); + if (IS_ERR(dgrp_class_nodes_dev)) { + ret = PTR_ERR(dgrp_class_nodes_dev); + goto err_group; + } + return 0; +err_group: + sysfs_remove_group(&dgrp_class_global_settings_dev->kobj, + &dgrp_global_settings_attribute_group); +err_dev1: + device_destroy(dgrp_class, MKDEV(0, max_majors + 1)); +err_file: + class_remove_file(dgrp_class, &class_attr_driver_version); +err_class: + class_destroy(dgrp_class); + return ret; } |