From 0a3fbb75359698a5a8f9f7533c7c9fa0ba477f03 Mon Sep 17 00:00:00 2001 From: Minsik Jeon Date: Wed, 11 Dec 2024 14:39:37 +0900 Subject: [PATCH] plugins/ocp: Align ocp_smart_extended_log struct. If the dssd point, minor version are declared as __le16, the alignment will be broken. Remove __packed keyword. Reported-by: Steven Seungcheol Lee Signed-off-by: Minsik Jeon --- plugins/ocp/ocp-print-json.c | 4 ++-- plugins/ocp/ocp-print-stdout.c | 4 ++-- plugins/ocp/ocp-smart-extended-log.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/ocp/ocp-print-json.c b/plugins/ocp/ocp-print-json.c index 36b3510ff3..a25d7e0a06 100644 --- a/plugins/ocp/ocp-print-json.c +++ b/plugins/ocp/ocp-print-json.c @@ -230,9 +230,9 @@ static void json_smart_extended_log(struct ocp_smart_extended_log *log) json_object_add_value_uint(root, "Errata Version Field", log->dssd_errata_version); json_object_add_value_uint(root, "Point Version Field", - le16_to_cpu(log->dssd_point_version)); + le16_to_cpu(*(uint16_t *)&log->dssd_point_version)); json_object_add_value_uint(root, "Minor Version Field", - le16_to_cpu(log->dssd_minor_version)); + le16_to_cpu(*(uint16_t *)&log->dssd_minor_version)); json_object_add_value_uint(root, "Major Version Field", log->dssd_major_version); json_object_add_value_uint(root, "NVMe Base Errata Version", diff --git a/plugins/ocp/ocp-print-stdout.c b/plugins/ocp/ocp-print-stdout.c index 37289714a5..f88e1c6674 100644 --- a/plugins/ocp/ocp-print-stdout.c +++ b/plugins/ocp/ocp-print-stdout.c @@ -177,9 +177,9 @@ static void stdout_smart_extended_log(struct ocp_smart_extended_log *log) printf(" Errata Version Field %d\n", log->dssd_errata_version); printf(" Point Version Field %"PRIu16"\n", - le16_to_cpu(log->dssd_point_version)); + le16_to_cpu(*(uint16_t *)&log->dssd_point_version)); printf(" Minor Version Field %"PRIu16"\n", - le16_to_cpu(log->dssd_minor_version)); + le16_to_cpu(*(uint16_t *)&log->dssd_minor_version)); printf(" Major Version Field %d\n", log->dssd_major_version); printf(" NVMe Base Errata Version %d\n", diff --git a/plugins/ocp/ocp-smart-extended-log.h b/plugins/ocp/ocp-smart-extended-log.h index 9b190d7ef2..6b806903e0 100644 --- a/plugins/ocp/ocp-smart-extended-log.h +++ b/plugins/ocp/ocp-smart-extended-log.h @@ -58,7 +58,7 @@ struct plugin; * @log_page_version: Log page version * @log_page_guid: Log page GUID */ -struct __packed ocp_smart_extended_log { +struct ocp_smart_extended_log { __u8 physical_media_units_written[16]; /* [15:0] */ __u8 physical_media_units_read[16]; /* [31:16] */ __u8 bad_user_nand_blocks_raw[6]; /* [37:32] */ @@ -77,8 +77,8 @@ struct __packed ocp_smart_extended_log { __u8 thermal_throttling_event_count; /* [96] */ __u8 thermal_throttling_current_status; /* [97] */ __u8 dssd_errata_version; /* [98] */ - __le16 dssd_point_version; /* [100:99] */ - __le16 dssd_minor_version; /* [102:101] */ + __u8 dssd_point_version[2]; /* [100:99] */ + __u8 dssd_minor_version[2]; /* [102:101] */ __u8 dssd_major_version; /* [103] */ __le64 pcie_correctable_err_count; /* [111:104] */ __le32 incomplete_shoutdowns; /* [115:112] */