Skip to content

Commit b7a4dd9

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 <sc108.lee@samsung.com> Signed-off-by: Minsik Jeon <hmi.jeon@samsung.com>
1 parent 65d7e7d commit b7a4dd9

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
@@ -230,9 +230,9 @@ static void json_smart_extended_log_v1(struct ocp_smart_extended_log *log)
230230
json_object_add_value_uint(root, "Errata Version Field",
231231
log->dssd_errata_version);
232232
json_object_add_value_uint(root, "Point Version Field",
233-
le16_to_cpu(log->dssd_point_version));
233+
le16_to_cpu(*(uint16_t *)&log->dssd_point_version));
234234
json_object_add_value_uint(root, "Minor Version Field",
235-
le16_to_cpu(log->dssd_minor_version));
235+
le16_to_cpu(*(uint16_t *)&log->dssd_minor_version));
236236
json_object_add_value_uint(root, "Major Version Field",
237237
log->dssd_major_version);
238238
json_object_add_value_uint(root, "NVMe Base Errata Version",
@@ -341,9 +341,9 @@ static void json_smart_extended_log_v2(struct ocp_smart_extended_log *log)
341341
json_object_add_value_uint(root, "errata_version_field",
342342
log->dssd_errata_version);
343343
json_object_add_value_uint(root, "point_version_field",
344-
le16_to_cpu(log->dssd_point_version));
344+
le16_to_cpu(*(uint16_t *)&log->dssd_point_version));
345345
json_object_add_value_uint(root, "minor_version_field",
346-
le16_to_cpu(log->dssd_minor_version));
346+
le16_to_cpu(*(uint16_t *)&log->dssd_minor_version));
347347
json_object_add_value_uint(root, "major_version_field",
348348
log->dssd_major_version);
349349
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
@@ -177,9 +177,9 @@ static void stdout_smart_extended_log(struct ocp_smart_extended_log *log, unsign
177177
printf(" Errata Version Field %d\n",
178178
log->dssd_errata_version);
179179
printf(" Point Version Field %"PRIu16"\n",
180-
le16_to_cpu(log->dssd_point_version));
180+
le16_to_cpu(*(uint16_t *)&log->dssd_point_version));
181181
printf(" Minor Version Field %"PRIu16"\n",
182-
le16_to_cpu(log->dssd_minor_version));
182+
le16_to_cpu(*(uint16_t *)&log->dssd_minor_version));
183183
printf(" Major Version Field %d\n",
184184
log->dssd_major_version);
185185
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)