]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
greybus: loopback: ensure debugfs entires are cleaned up on exit
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Mon, 14 Sep 2015 09:48:42 +0000 (10:48 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 15 Sep 2015 04:35:58 +0000 (21:35 -0700)
bdd4bba4 ('greybus/loopback: add module level sys/debug fs data points')
added a debugfs entry attached to gb_dev but omitted the cleanup on gb_init
error and gb_exit. This patchs fixes the missing debugfs_remove().

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reported-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/loopback.c

index 745490af7e477a087b830083374b4fe87f8eae75..8bfeec8f71a023dc9ad9253ca86a4b2c72a29852 100644 (file)
@@ -34,6 +34,7 @@ struct gb_loopback_stats {
 
 struct gb_loopback_device {
        struct dentry *root;
+       struct dentry *file;
        u32 count;
 
        struct kfifo kfifo;
@@ -860,9 +861,9 @@ static int gb_loopback_connection_init(struct gb_connection *connection)
        if (!gb_dev.count) {
                snprintf(name, sizeof(name), "raw_latency_endo0:%d",
                         connection->bundle->intf->module->module_id);
-               debugfs_create_file(name, S_IFREG | S_IRUGO,
-                                   gb_dev.root, &gb_dev,
-                                   &gb_loopback_debugfs_dev_latency_ops);
+               gb_dev.file = debugfs_create_file(name, S_IFREG | S_IRUGO,
+                                                 gb_dev.root, &gb_dev,
+                                 &gb_loopback_debugfs_dev_latency_ops);
                retval = sysfs_create_groups(kobj, loopback_dev_groups);
                if (retval)
                        goto out_sysfs;
@@ -925,8 +926,10 @@ out_kfifo0:
 out_sysfs_conn:
        sysfs_remove_groups(&connection->dev.kobj, loopback_con_groups);
 out_sysfs_dev:
-       if (!gb_dev.count)
+       if (!gb_dev.count) {
                sysfs_remove_groups(kobj, loopback_dev_groups);
+               debugfs_remove(gb_dev.file);
+       }
        debugfs_remove(gb->file);
        connection->private = NULL;
 out_sysfs:
@@ -950,8 +953,10 @@ static void gb_loopback_connection_exit(struct gb_connection *connection)
        kfifo_free(&gb->kfifo_lat);
        kfifo_free(&gb->kfifo_ts);
        gb_dev.count--;
-       if (!gb_dev.count)
+       if (!gb_dev.count) {
                sysfs_remove_groups(kobj, loopback_dev_groups);
+               debugfs_remove(gb_dev.file);
+       }
        sysfs_remove_groups(&connection->dev.kobj, loopback_con_groups);
        debugfs_remove(gb->file);
        list_del(&gb->entry);