From 9317c41ed75364f8f40cc9ceeba9dee4caa9ce61 Mon Sep 17 00:00:00 2001 From: Grzegorz Jaszczyk Date: Mon, 21 Mar 2022 09:24:04 +0000 Subject: [PATCH] acpi: improve check against acpi_mc_group id and improve error msgs Make sure that the group id received from get_acpi_event_group is not 0 before proceeding it further. At the occasion improve some error messages. As per review comments: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3407321/27 that I didn't make before it was merged. BUG=None TEST=Build and boot volteer-manatee Change-Id: I41a77fc3de10b13905f3f94277d2284acf29e67f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539980 Reviewed-by: Daniel Verkamp Tested-by: kokoro Commit-Queue: Grzegorz Jaszczyk --- devices/src/acpi.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/devices/src/acpi.rs b/devices/src/acpi.rs index 9b0a707826..805171c103 100644 --- a/devices/src/acpi.rs +++ b/devices/src/acpi.rs @@ -23,9 +23,9 @@ pub enum ACPIPMError { /// Error while waiting for events. #[error("failed to wait for events: {0}")] WaitError(SysError), - #[error("Did not found group_id corresponding to acpi_mc_group")] + #[error("Did not find group_id corresponding to acpi_mc_group")] AcpiMcGroupError, - #[error("Failed to create and bind NETLINK_GENERIC socket, listening on acpi_mc_group: {0}")] + #[error("Failed to create and bind NETLINK_GENERIC socket for acpi_mc_group: {0}")] AcpiEventSockError(base::Error), } @@ -174,11 +174,11 @@ fn run_worker( // Get group id corresponding to acpi_mc_group of acpi_event family let nl_groups: u32; match get_acpi_event_group() { - Some(group) => { + Some(group) if group > 0 => { nl_groups = 1 << (group - 1); info!("Listening on acpi_mc_group of acpi_event family"); } - None => { + _ => { return Err(ACPIPMError::AcpiMcGroupError); } }