public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] platform/x86/dell/dell-rbtn: Fix resources leaking on error path
@ 2023-06-12  9:02 Michal Wilczynski
  2023-06-12 11:21 ` Rafael J. Wysocki
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Michal Wilczynski @ 2023-06-12  9:02 UTC (permalink / raw)
  To: linux-acpi
  Cc: rafael, andriy.shevchenko, ilpo.jarvinen, pali, hdegoede,
	markgross, fengguang.wu, dvhart, platform-driver-x86,
	linux-kernel

Currently rbtn_add() in case of failure is leaking resources. Fix this
by adding a proper rollback. While at it, remove unnecessary assignment
of NULL to device->driver_data and unnecessary whitespace, plus add a
break for the default case in a switch.

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fixes: 817a5cdb40c8 ("dell-rbtn: Dell Airplane Mode Switch driver")
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/dell/dell-rbtn.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/dell/dell-rbtn.c b/drivers/platform/x86/dell/dell-rbtn.c
index aa0e6c907494..e9b3f9c3ab7d 100644
--- a/drivers/platform/x86/dell/dell-rbtn.c
+++ b/drivers/platform/x86/dell/dell-rbtn.c
@@ -420,10 +420,12 @@ static int rbtn_add(struct acpi_device *device)
 		break;
 	default:
 		ret = -EINVAL;
+		break;
 	}
+	if (ret)
+		rbtn_acquire(device, false);
 
 	return ret;
-
 }
 
 static void rbtn_remove(struct acpi_device *device)
@@ -442,7 +444,6 @@ static void rbtn_remove(struct acpi_device *device)
 	}
 
 	rbtn_acquire(device, false);
-	device->driver_data = NULL;
 }
 
 static void rbtn_notify(struct acpi_device *device, u32 event)
-- 
2.40.1


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

end of thread, other threads:[~2023-06-13 10:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-12  9:02 [PATCH v1] platform/x86/dell/dell-rbtn: Fix resources leaking on error path Michal Wilczynski
2023-06-12 11:21 ` Rafael J. Wysocki
2023-06-12 17:52 ` Pali Rohár
2023-06-12 20:52   ` Andy Shevchenko
2023-06-12 20:58     ` Pali Rohár
2023-06-12 21:02       ` Andy Shevchenko
2023-06-13  9:28 ` Ilpo Järvinen
2023-06-13  9:57   ` Wilczynski, Michal

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