Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1651504

[PATCH v2 07/27] thunderbolt: Allow passing NULL to tb_ctl_free()

From Mika Westerberg <mika.westerberg@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH v2 07/27] thunderbolt: Allow passing NULL to tb_ctl_free()
Date 2017-05-26 18:20 +0200
Message-ID <tLq83-87A-69@gated-at.bofh.it> (permalink)
References <tLq81-87A-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/ctl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
index 889a32dd21e7..f8290a577b2b 100644
--- a/drivers/thunderbolt/ctl.c
+++ b/drivers/thunderbolt/ctl.c
@@ -520,6 +520,10 @@ struct tb_ctl *tb_ctl_alloc(struct tb_nhi *nhi, hotplug_cb cb, void *cb_data)
 void tb_ctl_free(struct tb_ctl *ctl)
 {
 	int i;
+
+	if (!ctl)
+		return;
+
 	if (ctl->rx)
 		ring_free(ctl->rx);
 	if (ctl->tx)
-- 
2.11.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH v2 07/27] thunderbolt: Allow passing NULL to tb_ctl_free() Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-05-26 18:20 +0200
  Re: [PATCH v2 07/27] thunderbolt: Allow passing NULL to tb_ctl_free() Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-05-27 17:50 +0200
    Re: [PATCH v2 07/27] thunderbolt: Allow passing NULL to tb_ctl_free() Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-05-28 10:20 +0200
      Re: [PATCH v2 07/27] thunderbolt: Allow passing NULL to  tb_ctl_free() Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-05-29 14:20 +0200

csiph-web