greybus: loopback: ensure count decrement happens before sysfs_remove_groups
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Mon, 14 Sep 2015 09:48:39 +0000 (10:48 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 15 Sep 2015 04:35:58 +0000 (21:35 -0700)
This patches fixes a case where gb_dev.count is decremented too late in the
exit() routine.

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

index 231d1d4..33c21cf 100644 (file)
@@ -952,14 +952,13 @@ static void gb_loopback_connection_exit(struct gb_connection *connection)
        connection->private = NULL;
        kfifo_free(&gb->kfifo_lat);
        kfifo_free(&gb->kfifo_ts);
+       gb_dev.count--;
        if (!gb_dev.count)
                sysfs_remove_groups(kobj, loopback_dev_groups);
        sysfs_remove_groups(&connection->dev.kobj, loopback_con_groups);
        debugfs_remove(gb->file);
        list_del(&gb->entry);
        kfree(gb);
-       gb_dev.count--;
-
        mutex_unlock(&gb_dev.mutex);
 }