From 4ec33d0b760b4eee4da989dccb88a695332719b2 Mon Sep 17 00:00:00 2001 From: Niklas Schnelle Date: Thu, 5 Dec 2024 15:05:11 +0100 Subject: [PATCH] zpcictl: Use actual instead of max length in SCLP report MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SCLP report currently always uses the maximum length even if no extra data is proved at all. Instead use the actual length of either just the timestamp and err_log_id or additionally the length of sdata. Reviewed-by: Halil Pasic Signed-off-by: Niklas Schnelle Signed-off-by: Jan Höppner --- zpcictl/zpcictl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zpcictl/zpcictl.c b/zpcictl/zpcictl.c index c8aaf1ec..8f27f577 100644 --- a/zpcictl/zpcictl.c +++ b/zpcictl/zpcictl.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -333,15 +334,15 @@ static void sclp_issue_action(struct zpci_device *pdev, int action) report.header.version = 1; report.header.action = action; - report.header.length = sizeof(report.data); + report.header.length = offsetof(struct zpci_report_error_data, log_data); report.data.timestamp = (__u64)time(NULL); report.data.err_log_id = 0x4713; if (pdev->class == PCI_CLASS_NVME) sdata = collect_smart_data(pdev); if (sdata) { - util_strlcpy(report.data.log_data, sdata, - sizeof(report.data.log_data)); + report.header.length += util_strlcpy(report.data.log_data, sdata, + sizeof(report.data.log_data)); free(sdata); } sysfs_report_error(&report, pdev->slot);