Skip to content

Commit eb9a59b

Browse files
committed
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. Change parameter void to ocp_smart_extended_log. Reported-by: Steven Seungcheol Lee <[email protected]> Signed-off-by: Minsik Jeon <[email protected]>
1 parent 6e5abc5 commit eb9a59b

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

plugins/ocp/ocp-print-json.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ static void json_smart_extended_log_v1(struct ocp_smart_extended_log *log)
232232
json_object_add_value_uint(root, "Errata Version Field",
233233
log->dssd_errata_version);
234234
json_object_add_value_uint(root, "Point Version Field",
235-
le16_to_cpu(log->dssd_point_version));
235+
le16_to_cpu(*(uint16_t *)&log->dssd_point_version));
236236
json_object_add_value_uint(root, "Minor Version Field",
237-
le16_to_cpu(log->dssd_minor_version));
237+
le16_to_cpu(*(uint16_t *)&log->dssd_minor_version));
238238
json_object_add_value_uint(root, "Major Version Field",
239239
log->dssd_major_version);
240240
json_object_add_value_uint(root, "NVMe Base Errata Version",
@@ -343,9 +343,9 @@ static void json_smart_extended_log_v2(struct ocp_smart_extended_log *log)
343343
json_object_add_value_uint(root, "errata_version_field",
344344
log->dssd_errata_version);
345345
json_object_add_value_uint(root, "point_version_field",
346-
le16_to_cpu(log->dssd_point_version));
346+
le16_to_cpu(*(uint16_t *)&log->dssd_point_version));
347347
json_object_add_value_uint(root, "minor_version_field",
348-
le16_to_cpu(log->dssd_minor_version));
348+
le16_to_cpu(*(uint16_t *)&log->dssd_minor_version));
349349
json_object_add_value_uint(root, "major_version_field",
350350
log->dssd_major_version);
351351
json_object_add_value_uint(root, "nvme_base_errata_version",

plugins/ocp/ocp-print-stdout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ static void stdout_smart_extended_log(struct ocp_smart_extended_log *log, unsign
176176
printf(" Errata Version Field %d\n",
177177
log->dssd_errata_version);
178178
printf(" Point Version Field %"PRIu16"\n",
179-
le16_to_cpu(log->dssd_point_version));
179+
le16_to_cpu(*(uint16_t *)&log->dssd_point_version));
180180
printf(" Minor Version Field %"PRIu16"\n",
181-
le16_to_cpu(log->dssd_minor_version));
181+
le16_to_cpu(*(uint16_t *)&log->dssd_minor_version));
182182
printf(" Major Version Field %d\n",
183183
log->dssd_major_version);
184184
printf(" NVMe Base Errata Version %d\n",

plugins/ocp/ocp-print.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ void ocp_fw_act_history(const struct fw_activation_history *fw_history, nvme_pri
3636
ocp_print(fw_act_history, flags, fw_history);
3737
}
3838

39-
void ocp_smart_extended_log(void *data, unsigned int version, nvme_print_flags_t flags)
39+
void ocp_smart_extended_log(struct ocp_smart_extended_log *log, unsigned int version,
40+
nvme_print_flags_t flags)
4041
{
41-
ocp_print(smart_extended_log, flags, data, version);
42+
ocp_print(smart_extended_log, flags, log, version);
4243
}
4344

4445
void ocp_show_telemetry_log(struct ocp_telemetry_parse_options *options, nvme_print_flags_t flags)

plugins/ocp/ocp-print.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ static inline struct ocp_print_ops *ocp_get_json_print_ops(nvme_print_flags_t fl
3737

3838
void ocp_show_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list, nvme_print_flags_t flags);
3939
void ocp_fw_act_history(const struct fw_activation_history *fw_history, nvme_print_flags_t flags);
40-
void ocp_smart_extended_log(void *data, unsigned int version, nvme_print_flags_t flags);
40+
void ocp_smart_extended_log(struct ocp_smart_extended_log *log, unsigned int version,
41+
nvme_print_flags_t flags);
4142
void ocp_show_telemetry_log(struct ocp_telemetry_parse_options *options, nvme_print_flags_t flags);
4243
void ocp_c3_log(struct nvme_dev *dev, struct ssd_latency_monitor_log *log_data,
4344
nvme_print_flags_t flags);

plugins/ocp/ocp-smart-extended-log.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct plugin;
5858
* @log_page_version: Log page version
5959
* @log_page_guid: Log page GUID
6060
*/
61-
struct __packed ocp_smart_extended_log {
61+
struct ocp_smart_extended_log {
6262
__u8 physical_media_units_written[16]; /* [15:0] */
6363
__u8 physical_media_units_read[16]; /* [31:16] */
6464
__u8 bad_user_nand_blocks_raw[6]; /* [37:32] */
@@ -77,8 +77,8 @@ struct __packed ocp_smart_extended_log {
7777
__u8 thermal_throttling_event_count; /* [96] */
7878
__u8 thermal_throttling_current_status; /* [97] */
7979
__u8 dssd_errata_version; /* [98] */
80-
__le16 dssd_point_version; /* [100:99] */
81-
__le16 dssd_minor_version; /* [102:101] */
80+
__u8 dssd_point_version[2]; /* [100:99] */
81+
__u8 dssd_minor_version[2]; /* [102:101] */
8282
__u8 dssd_major_version; /* [103] */
8383
__le64 pcie_correctable_err_count; /* [111:104] */
8484
__le32 incomplete_shoutdowns; /* [115:112] */

0 commit comments

Comments
 (0)