thunderbolt: Allow passing NULL to tb_ctl_free()
authorMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 6 Jun 2017 12:24:59 +0000 (15:24 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Jun 2017 09:42:41 +0000 (11:42 +0200)
Following the usual pattern used in many places, we allow passing NULL
pointer to tb_ctl_free(). Then the user can call the function regardless
if it has allocated control channel or not making the code bit simpler.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/thunderbolt/ctl.c

index 889a32dd21e7aebf4e14528f2b88f5704b89d99d..f8290a577b2ba6cdd2948fe8d79f8e519bbf072c 100644 (file)
@@ -520,6 +520,10 @@ err:
 void tb_ctl_free(struct tb_ctl *ctl)
 {
        int i;
+
+       if (!ctl)
+               return;
+
        if (ctl->rx)
                ring_free(ctl->rx);
        if (ctl->tx)