From 74eaa374c107d1a9e140fc7a8c1bf91386619940 Mon Sep 17 00:00:00 2001 From: Kota Tsuyuzaki Date: Thu, 3 Nov 2016 19:49:49 -0700 Subject: Fix error handling on gf_ivnert_matrix in isa-l backend Current isa-l has possibility to return corrupted decoded data or corrupted reconstructed data on decode/reconstruct without error code. That is from the specification of isa-l rs vandermond matrix discussed at [1]. With many # of parities cases, we may hit the case above due to failing to get the inverse matrix from the encode matrix. The isa-l maintener gbtucker suggests a good way to detect the failing inverse matrix, that we should handle the return value gf_invert_matrix. If gf_invert_matrix returns not 0, we should stop to decode/reconstruct and return failure return code to the caller immediately. Otherwise, the caller regards the garbage data/fragment as correct one. And this patch adds the specific test case we can hit the issue (it happens not so general). 1: https://github.com/01org/isa-l/issues/10 Related-Change: I6eb150d9d0c3febf233570fa7729f9f72df2e9be Change-Id: Icee788a0931fe692fe0de31fabc4ba450e338a87 --- src/backends/isa-l/isa_l_rs_vand.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/backends/isa-l/isa_l_rs_vand.c b/src/backends/isa-l/isa_l_rs_vand.c index d2f740f..ebce441 100644 --- a/src/backends/isa-l/isa_l_rs_vand.c +++ b/src/backends/isa-l/isa_l_rs_vand.c @@ -261,7 +261,10 @@ static int isa_l_rs_vand_decode(void *desc, char **data, char **parity, goto out; } - isa_l_desc->gf_invert_matrix(decode_matrix, decode_inverse, k); + int im_ret = isa_l_desc->gf_invert_matrix(decode_matrix, decode_inverse, k); + if (im_ret < 0) { + goto out; + } // Generate g_tbls from computed decode matrix (k x k) matrix g_tbls = malloc(sizeof(unsigned char) * (k * m * 32)); @@ -365,7 +368,10 @@ static int isa_l_rs_vand_reconstruct(void *desc, char **data, char **parity, goto out; } - isa_l_desc->gf_invert_matrix(decode_matrix, decode_inverse, k); + int im_ret = isa_l_desc->gf_invert_matrix(decode_matrix, decode_inverse, k); + if (im_ret < 0) { + goto out; + } /** * Get the row needed to reconstruct -- cgit v1.2.1