From cf2311f1f1de17435b49ba8c8697be91705ba031 Mon Sep 17 00:00:00 2001 From: Ingo Franzki Date: Wed, 11 Nov 2020 10:22:30 +0100 Subject: [PATCH] zcryptstats: Fix handling of partial results with many domains MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When many domains per card are available, then the results of the SCDMD CHSC call may not fit into the output area, and a partial result is returned. The further results must be retrieved with another CHSC call. Fix the code to pass the correct next-domain to the subsequent CHSC call of a partial response. Otherwise the same set of domains 1 to n are retrieved again, resulting in an infinite loop, because this will always produce a partial result. Signed-off-by: Ingo Franzki Reviewed-by: Harald Freudenberger Signed-off-by: Jan Höppner --- zconf/zcrypt/zcryptstats.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/zconf/zcrypt/zcryptstats.c b/zconf/zcrypt/zcryptstats.c index 3bb20787..2456e5db 100644 --- a/zconf/zcrypt/zcryptstats.c +++ b/zconf/zcrypt/zcryptstats.c @@ -1178,8 +1178,14 @@ static int get_apqn_measurement_data(uint8_t card) scdmd_area.request.header.code = 0x102d; scdmd_area.request.header.length = sizeof(struct chsc_scdmd_request); - scdmd_area.request.first_drid.ap_index = card; - scdmd_area.request.first_drid.domain_index = g.min_domain; + if (scdmd_area.response.p) { + scdmd_area.request.first_drid = + scdmd_area.response.crid; + } else { + scdmd_area.request.first_drid.ap_index = card; + scdmd_area.request.first_drid.domain_index = + g.min_domain; + } scdmd_area.request.last_drid.ap_index = card; scdmd_area.request.last_drid.domain_index = g.max_domain; scdmd_area.request.s = 1; @@ -1217,10 +1223,6 @@ static int get_apqn_measurement_data(uint8_t card) rc = process_apqn_measurement_data(&scdmd_area); if (rc != 0) break; - - if (scdmd_area.response.p) - scdmd_area.request.first_drid = - scdmd_area.response.crid; } while (scdmd_area.response.p); return rc;