public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thunderbolt: Use common error handling code in update_property_block()
@ 2024-09-25  8:10 Markus Elfring
  2024-09-25  8:45 ` Mika Westerberg
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Markus Elfring @ 2024-09-25  8:10 UTC (permalink / raw)
  To: linux-usb, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 25 Sep 2024 09:39:16 +0200

Add a jump target so that a bit of exception handling can be better reused
at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/thunderbolt/xdomain.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index 11a50c86a1e4..8e3cf95ca99c 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -670,23 +670,19 @@ static void update_property_block(struct tb_xdomain *xd)
 		ret = tb_property_format_dir(dir, NULL, 0);
 		if (ret < 0) {
 			dev_warn(&xd->dev, "local property block creation failed\n");
-			tb_property_free_dir(dir);
-			goto out_unlock;
+			goto out_free_dir;
 		}

 		block_len = ret;
 		block = kcalloc(block_len, sizeof(*block), GFP_KERNEL);
-		if (!block) {
-			tb_property_free_dir(dir);
-			goto out_unlock;
-		}
+		if (!block)
+			goto out_free_dir;

 		ret = tb_property_format_dir(dir, block, block_len);
 		if (ret) {
 			dev_warn(&xd->dev, "property block generation failed\n");
-			tb_property_free_dir(dir);
 			kfree(block);
-			goto out_unlock;
+			goto out_free_dir;
 		}

 		tb_property_free_dir(dir);
@@ -701,6 +697,11 @@ static void update_property_block(struct tb_xdomain *xd)
 out_unlock:
 	mutex_unlock(&xd->lock);
 	mutex_unlock(&xdomain_lock);
+	return;
+
+out_free_dir:
+	tb_property_free_dir(dir);
+	goto out_unlock;
 }

 static void start_handshake(struct tb_xdomain *xd)
--
2.46.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-09-26  1:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25  8:10 [PATCH] thunderbolt: Use common error handling code in update_property_block() Markus Elfring
2024-09-25  8:45 ` Mika Westerberg
2024-09-25  9:20   ` Markus Elfring
2024-09-25  9:35     ` Mika Westerberg
2024-09-25  9:40       ` Markus Elfring
2024-09-25  9:42         ` Greg KH
2024-09-25 23:58 ` [PATCH] " kernel test robot
2024-09-26  1:52 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox