crypto: octeontx2 - prevent underflow in get_cores_bmap()

[ Upstream commit 10371b6212 ]

If we're going to cap "eng_grp->g->engs_num" upper bounds then we should
cap the lower bounds as well.

Fixes: 43ac0b824f ("crypto: octeontx2 - load microcode and create engine groups")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Dan Carpenter 2021-12-17 10:13:32 +03:00 коммит произвёл Greg Kroah-Hartman
Родитель 910e5e8ac5
Коммит 78cafdf7d2
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -29,7 +29,8 @@ static struct otx2_cpt_bitmap get_cores_bmap(struct device *dev,
bool found = false;
int i;
if (eng_grp->g->engs_num > OTX2_CPT_MAX_ENGINES) {
if (eng_grp->g->engs_num < 0 ||
eng_grp->g->engs_num > OTX2_CPT_MAX_ENGINES) {
dev_err(dev, "unsupported number of engines %d on octeontx2\n",
eng_grp->g->engs_num);
return bmap;