From eec836eb731767eb2a0e8d86757de605bfd148d6 Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Tue, 18 Feb 2020 10:03:30 +0000 Subject: IVGCVSW-4375 Fixed driver crashes * Fixed driver crashes caused by ignoring the result of GetTensorInt32Values. * Fixed driver crashes where padding, axis, permutation dimension or block size operands were inputs. Signed-off-by: Mike Kelly Change-Id: I59867e9545a240e6be46b7f68da6adaa120a56d8 --- ConversionUtils.hpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ConversionUtils.hpp b/ConversionUtils.hpp index 550c3201..5c6238e2 100644 --- a/ConversionUtils.hpp +++ b/ConversionUtils.hpp @@ -1399,7 +1399,10 @@ bool ConvertPaddings(const HalOperation& operation, } std::vector paddings; - GetTensorInt32Values(*paddingsOperand, paddings, model, data); + if (!GetTensorInt32Values(*paddingsOperand, paddings, model, data)) + { + return Fail("%s: Operation has invalid or unsupported paddings operand", __func__); + } // add padding for each dimension of input tensor. for (unsigned int i = 0; i < paddings.size() - 1; i += 2) @@ -3271,9 +3274,9 @@ bool ConvertSqueeze(const HalOperation& operation, const HalModel& model, Conver axis.assign(dimensionSequence, dimensionSequence + rank); } - else + else if (!GetTensorInt32Values(*axisOperand, axis, model, data)) { - GetTensorInt32Values(*axisOperand, axis, model, data); + return Fail("%s: Operation has an invalid or unsupported axis operand", __func__); } std::vector outputDims; @@ -3451,9 +3454,9 @@ bool ConvertTranspose(const HalOperation& operation, const HalModel& model, Conv perm[rank - i] = boost::numeric_cast (i - 1); } } - else + else if (!GetTensorInt32Values(*permOperand, perm, model, data)) { - GetTensorInt32Values(*permOperand, perm, model, data); + return Fail("%s: Operation has an invalid or unsupported permutation operand", __func__); } std::vector outputDims(perm.begin(), perm.begin() + rank); @@ -3634,7 +3637,10 @@ bool ConvertSpaceToBatchNd(const HalOperation& operation, const HalModel& model, } std::vector blockShape; - GetTensorInt32Values(*blockShapeOperand, blockShape, model, data); + if (!GetTensorInt32Values(*blockShapeOperand, blockShape, model, data)) + { + return Fail("%s: Operation has an invalid or unsupported block size operand", __func__); + } if (std::any_of(blockShape.cbegin(), blockShape.cend(), [](int32_t i){ return i < 1; })) { return Fail("%s: Block shape must be at least 1 in all dimensions.", __func__); @@ -3648,7 +3654,10 @@ bool ConvertSpaceToBatchNd(const HalOperation& operation, const HalModel& model, std::vector> paddingList; std::vector paddings; - GetTensorInt32Values(*paddingsOperand, paddings, model, data); + if (!GetTensorInt32Values(*paddingsOperand, paddings, model, data)) + { + return Fail("%s: Operation has an invalid or unsupported paddings operand", __func__); + } for (unsigned int i = 0; i < paddings.size() - 1; i += 2) { int paddingBeforeInput = paddings[i]; -- cgit v1.2.1