linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI: scan: Make acpi_bus_get_device() clear the adev ptr on error
@ 2021-01-15 21:57 Hans de Goede
  2021-01-18 13:58 ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2021-01-15 21:57 UTC (permalink / raw)
  To: Rafael J . Wysocki; +Cc: Hans de Goede, linux-acpi, Pierre-Louis Bossart

Set the acpi_device pointer which acpi_bus_get_device()
returns-by-reference to NULL on error.

We've recently had 2 cases where callers of acpi_bus_get_device()
did not properly error check the return value, using the
returned-by-reference acpi_device pointer blindly, set it to NULL
so that this will lead to an immediate oops, rather then following
a pointer to who knows what.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/scan.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index c575c9b67f76..c53e88deee1d 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -585,6 +585,8 @@ static int acpi_get_device_data(acpi_handle handle, struct acpi_device **device,
 	if (!device)
 		return -EINVAL;
 
+	*device = NULL;
+
 	status = acpi_get_data_full(handle, acpi_scan_drop_device,
 				    (void **)device, callback);
 	if (ACPI_FAILURE(status) || !*device) {
-- 
2.28.0


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

end of thread, other threads:[~2021-01-19 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-15 21:57 [PATCH] ACPI: scan: Make acpi_bus_get_device() clear the adev ptr on error Hans de Goede
2021-01-18 13:58 ` Rafael J. Wysocki
2021-01-18 16:08   ` Hans de Goede
2021-01-18 16:21     ` Rafael J. Wysocki
2021-01-18 16:23       ` Hans de Goede
2021-01-19 15:41   ` Pierre-Louis Bossart

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).