Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1299475lqz; Mon, 1 Apr 2024 01:26:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXrtLY2WJuaomUMLZ1goYmlvgXXMWat6ltkKFDLbLCiBXSfJ2A49GTidpDaSPcgNcM6ZzE78fI6ynm91E/tXiOHTKpVqQQD68b0MkXN2w== X-Google-Smtp-Source: AGHT+IHIRLU6FAJ6eG+zdMD2TDszx+kK1zoKCfetUWyOUlCRQIFRfR5nsu7rt+kQ3XmRW7xYe8aO X-Received: by 2002:a17:90a:c598:b0:2a2:1148:e17a with SMTP id l24-20020a17090ac59800b002a21148e17amr6893031pjt.30.1711960015446; Mon, 01 Apr 2024 01:26:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711960015; cv=pass; d=google.com; s=arc-20160816; b=WXsn7LMxnfzVNgs8YAEyNLHv9Oe85nc0tvN31nblX714vgAvn+gkjWO7aV/r8Bh8zh nMTDKGHCuDv+z1GijGdaU8V5Rf3zdhtqbDEUwTYPq/93x0hABqfIu0Iy3CVyNCUEnQwL N+FC6qB5aFTu/o4Aco7OZHlR3DURLvA/BUH53jDXnErJKwcOK8NDtRqujP6MrvSURyqV Z/BWdPIWa5PwW7834ucNCnNbZX+AW2A2yZUpYvqNJp8N5dA7NP0CXxM0aZdwrWmn7ivL j3eU0fW04sSbLJnRpdatx/PbfAbOWRV876ro3WlPyWjX1ORZy9OuM3t5Z3ziRXhcZ5ct lI0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=qiCJehYnFNeBM52UAmEX9XL0+c7i9RD43AhPAy7qD3c=; fh=f62YXMwnpptv74fKJTNsmBQ7E35s1aYHjtuNqqeK6GA=; b=n2jHakll3pQujTIu9O7gjTJI0huJNsN2knt/VsJDyPt1fy5BS8nQAv2S53MToJaCdK dhfkfmszF2u4rSRAPYz3SCIfKe0INpy/z5cUGP3r3HASTCnv+OwLH2GVuwMJIrI9qQ3N q1ilRgiu3cSZqTYiNAqI3JDTdygdzKZkeKBS9hLGZQFHqJAbF9KZm3/GEpfFlwi+b1Ee muCARYQ1NdUGk6BSkIGaF1S3nqSVvyiXxX8PVzcnOapCLs6xVvZwyaDLnn+OXOMhEO++ DYS0tu8WiwsZRcQN05DJ0a7Q8blznd44Yr7g2/dgjENPh5tBU7E4ssRaAoi0gEYyfn3h WU/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=usergate.com dmarc=pass fromdomain=usergate.com); spf=pass (google.com: domain of linux-crypto+bounces-3231-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3231-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=usergate.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f14-20020a17090aec8e00b002a238219047si2140242pjy.8.2024.04.01.01.26.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 01:26:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3231-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=usergate.com dmarc=pass fromdomain=usergate.com); spf=pass (google.com: domain of linux-crypto+bounces-3231-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3231-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=usergate.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D3690281C37 for ; Mon, 1 Apr 2024 08:26:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 370B8CA73; Mon, 1 Apr 2024 08:26:51 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from mx2.usergate.com (mx2.usergate.com [46.229.79.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E308CA4A; Mon, 1 Apr 2024 08:26:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.229.79.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711960011; cv=none; b=OsCfFJc7WHXfT4GUU7XJdkm53fPTvS/dOO6cF64HGhpsj6sBOv5a16bZfsruEUamAm9vR8UR4OenYb47oHPat6HVI0d1LLaqK5ZsKrOkVSMHl8wYv25tCb6YvL3BGOdBrUh16FcluJZHd3Qr9nFe1RIDGSmaYdWG5jt2UouV1xg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711960011; c=relaxed/simple; bh=C+J5MpnPgzyL3rxuVaYmd7nFhMJzSzKZIS0KTBM3aXQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=KO41V+BpjrxDzuMJbBtZ/tB7nn7PmjmcjYVIzBhEHcCP4r/HuIz94yHXPlAU9ktD0QTAk8cZB/RBJl5DXKWO94FS2DJ42xxn5FWOk0YtWew3Zf4K11RvhY84lIUgbt00IZ0LFhB9fNhbR1qVlJrCC2qlolyva5toWgIZatmsDLY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=usergate.com; spf=pass smtp.mailfrom=usergate.com; arc=none smtp.client-ip=46.229.79.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=usergate.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=usergate.com Received: from mail.usergate.com[192.168.90.36] by mx2.usergate.com with ESMTP id 04652200BE934873ABF0A2AD45B6DDE0; Mon, 1 Apr 2024 15:26:36 +0700 From: Aleksandr Aprelkov To: =?UTF-8?q?Horia=20Geant=C4=83?= CC: Aleksandr Aprelkov ,Pankaj Gupta ,Gaurav Jain ,Herbert Xu ,"David S. Miller" ,,, Subject: [PATCH] crypto: caam/qi2 - check for 0 rx/tx queues on setup Date: Mon, 1 Apr 2024 15:26:20 +0700 Message-ID: <20240401082620.608675-1-aaprelkov@usergate.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: ESLSRV-EXCH-01.esafeline.com (192.168.90.36) To nsk02-mbx01.esafeline.com (10.10.1.35) X-Message-Id: A2374E53DB9B4D068A738ABD47F8D0DA X-MailFileId: 4119093A5F4E48B48CDAFA9493532D4C If num_rx_queues or num_tx_queues is 0, then division by zero occurs on j calculation. Also goto mark "err_get_rx_queue" used for tx queues too. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 8d818c105501 ("crypto: caam/qi2 - add DPAA2-CAAM driver") Signed-off-by: Aleksandr Aprelkov --- drivers/crypto/caam/caamalg_qi2.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c index a4f6884416a0..07cb1aad758f 100644 --- a/drivers/crypto/caam/caamalg_qi2.c +++ b/drivers/crypto/caam/caamalg_qi2.c @@ -5049,6 +5049,11 @@ static int __cold dpaa2_dpseci_setup(struct fsl_mc_device *ls_dev) priv->num_pairs = min(priv->dpseci_attr.num_rx_queues, priv->dpseci_attr.num_tx_queues); + if (!priv->num_pairs) { + err = -EINVAL; + dev_err(dev, "one of queues number is 0\n"); + goto err_get_queues; + } if (priv->num_pairs > num_online_cpus()) { dev_warn(dev, "%d queues won't be used\n", priv->num_pairs - num_online_cpus()); @@ -5060,7 +5065,7 @@ static int __cold dpaa2_dpseci_setup(struct fsl_mc_device *ls_dev) &priv->rx_queue_attr[i]); if (err) { dev_err(dev, "dpseci_get_rx_queue() failed\n"); - goto err_get_rx_queue; + goto err_get_queues; } } @@ -5069,7 +5074,7 @@ static int __cold dpaa2_dpseci_setup(struct fsl_mc_device *ls_dev) &priv->tx_queue_attr[i]); if (err) { dev_err(dev, "dpseci_get_tx_queue() failed\n"); - goto err_get_rx_queue; + goto err_get_queues; } } @@ -5105,7 +5110,7 @@ static int __cold dpaa2_dpseci_setup(struct fsl_mc_device *ls_dev) return 0; -err_get_rx_queue: +err_get_queues: dpaa2_dpseci_congestion_free(priv); err_get_vers: dpseci_close(priv->mc_io, 0, ls_dev->mc_handle); -- 2.34.1