linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Sony-laptop: Use common error handling code in sony_nc_setup_rfkill()
@ 2017-10-30 20:15 SF Markus Elfring
  2017-10-31 13:33 ` Andy Shevchenko
  0 siblings, 1 reply; 19+ messages in thread
From: SF Markus Elfring @ 2017-10-30 20:15 UTC (permalink / raw)
  To: platform-driver-x86, Andy Shevchenko, Darren Hart, Mattia Dongili
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 30 Oct 2017 21:10:49 +0100

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

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/platform/x86/sony-laptop.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index a16cea2be9c3..3ab6e41a8ed6 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1660,18 +1660,16 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,
 	if (!rfk)
 		return -ENOMEM;
 
-	if (sony_call_snc_handle(sony_rfkill_handle, 0x200, &result) < 0) {
-		rfkill_destroy(rfk);
-		return -1;
-	}
+	if (sony_call_snc_handle(sony_rfkill_handle, 0x200, &result) < 0)
+		goto destroy_rfk;
+
 	hwblock = !(result & 0x1);
 
 	if (sony_call_snc_handle(sony_rfkill_handle,
-				sony_rfkill_address[nc_type],
-				&result) < 0) {
-		rfkill_destroy(rfk);
-		return -1;
-	}
+				 sony_rfkill_address[nc_type],
+				 &result) < 0)
+		goto destroy_rfk;
+
 	swblock = !(result & 0x2);
 
 	rfkill_init_sw_state(rfk, swblock);
@@ -1684,6 +1682,10 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,
 	}
 	sony_rfkill_devices[nc_type] = rfk;
 	return err;
+
+destroy_rfk:
+	rfkill_destroy(rfk);
+	return -1;
 }
 
 static void sony_nc_rfkill_update(void)
-- 
2.14.3

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

end of thread, other threads:[~2017-11-07 13:55 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-30 20:15 [PATCH] Sony-laptop: Use common error handling code in sony_nc_setup_rfkill() SF Markus Elfring
2017-10-31 13:33 ` Andy Shevchenko
2017-10-31 14:24   ` SF Markus Elfring
2017-10-31 16:35     ` Andy Shevchenko
2017-10-31 16:56       ` SF Markus Elfring
2017-11-01 18:45   ` [PATCH v2 0/3] Sony-laptop: Adjustments for sony_nc_setup_rfkill() SF Markus Elfring
2017-11-01 18:46     ` [PATCH v2 1/3] Sony-laptop: Fix exception handling in sony_nc_setup_rfkill() SF Markus Elfring
2017-11-03 12:00       ` Andy Shevchenko
2017-11-01 18:47     ` [PATCH v2 2/3] Sony-laptop: Delete an unnecessary variable initialisation " SF Markus Elfring
2017-11-03 12:00       ` Andy Shevchenko
2017-11-01 18:49     ` [PATCH v2 3/3] Sony-laptop: Use common error handling code " SF Markus Elfring
2017-11-03 12:02     ` [PATCH v2 0/3] Sony-laptop: Adjustments for sony_nc_setup_rfkill() Andy Shevchenko
2017-11-03 13:23       ` SF Markus Elfring
2017-11-05 13:24         ` Andy Shevchenko
2017-11-05 14:20           ` SF Markus Elfring
2017-11-07 12:49             ` Andy Shevchenko
2017-11-07 13:00               ` SF Markus Elfring
2017-11-07 13:18                 ` Andy Shevchenko
2017-11-07 13:54                   ` SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).