Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751695AbdFFMZe (ORCPT ); Tue, 6 Jun 2017 08:25:34 -0400 Received: from mga06.intel.com ([134.134.136.31]:10918 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751614AbdFFMZc (ORCPT ); Tue, 6 Jun 2017 08:25:32 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,306,1493708400"; d="scan'208";a="1157138547" From: Mika Westerberg To: Greg Kroah-Hartman Cc: Andreas Noever , Michael Jamet , Yehezkel Bernat , Lukas Wunner , Amir Levy , Andy Lutomirski , Mario.Limonciello@dell.com, Jared.Dominguez@dell.com, Andy Shevchenko , Mika Westerberg , linux-kernel@vger.kernel.org Subject: [PATCH v4 07/27] thunderbolt: Allow passing NULL to tb_ctl_free() Date: Tue, 6 Jun 2017 15:24:59 +0300 Message-Id: <20170606122519.35401-8-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170606122519.35401-1-mika.westerberg@linux.intel.com> References: <20170606122519.35401-1-mika.westerberg@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 890 Lines: 28 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 Signed-off-by: Mika Westerberg Signed-off-by: Andreas Noever --- 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