Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13022304rwd; Fri, 23 Jun 2023 14:27:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZVExAPfmzxt2H6jN55vtLQ8x2oHLdAWeEbUx0BWWk5hfXxXXLN3fm+qbPHy+ALcrnXvN9 X-Received: by 2002:a05:6a00:3994:b0:66a:3812:7eda with SMTP id fi20-20020a056a00399400b0066a38127edamr10107905pfb.9.1687555675451; Fri, 23 Jun 2023 14:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555675; cv=none; d=google.com; s=arc-20160816; b=Ojix6C6kl4oAtBt5pwsxbnv4ljuqYopt6LLeoJa4OQXpMXPF1kIx8cpbFX3nWy6N9C ci/xYOTeQmLbwirOLCY+BF/nSOWt5oiJcRKy0VIvqTR8cUXRRhlwOFO6kFvlNtHiyBJE fLkkUrcdrW17ak5HvefLCNQy4CauTKEW1fHYPhi5J9xePmuzzqvTh8sxf/QlPMjHoaBx u8t0AZLJNAmf2mx9HqdcSDReCYNWEqW7WjHBwmmH8Y6btBBFEqVvGMvDCswVhwrRyR1n d1h0KGDPv68CxTH82sjGKzATO/+UczJNDESPi9Sri7dPsqJmnzIsaQ9phxkB6L+rGGBJ lbAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CxJuiiXcSlU+s+aK2RdCGaJm2rWe7fLo/P4JyxZmwgU=; fh=OcI2ar8rmK11afESoLyKrSp1zPZ4RRBBhD+T3FlUyqQ=; b=yd8sGT4JjzAQMxFn5UioJ3TiNYaA34P7Ws/UBIzfiz72Nf9ywySFi3Wky8uZ6FPrJk 5yjzs/llX5UzWnoaWOWzg/WbsgH6vvsxNhzenWjwbB8UAaHyXdhmSe+LFzCaCaj2/o/u 2tvXixEYzE8+w1oq9ilFWzBKhtNUDglM2j0ds4Qn2Jlemqe/sxKE6XwSIBKekOaH7diW SvR7iVQR9V2LZhvnlQZrhufO1PunbvFIVhvGN+ZfOPrVXdI8drx7spTZM1G7pi4R8JH3 oFfrAsSvLfsz+MAHsAbzMiNSkURl2n5qvkSH7p+sQifBBoC5arqq2Uo5Nes/5fCaJho8 94UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=Y+TGJl9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h69-20020a638348000000b00553d074198fsi272840pge.137.2023.06.23.14.27.43; Fri, 23 Jun 2023 14:27:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=Y+TGJl9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232874AbjFWVQo (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232865AbjFWVQC (ORCPT ); Fri, 23 Jun 2023 17:16:02 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BAD82964; Fri, 23 Jun 2023 14:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CxJuiiXcSlU+s+aK2RdCGaJm2rWe7fLo/P4JyxZmwgU=; b=Y+TGJl9kktgLU2LOFT6pAr8H9vMhgFCXSpYoMx6YRcy0WlnrnJFEBdQe GjewKrO0T9ledIQTGIKjVzV4zVvZ85studPlRFdE6P9wCS23upj1v7+Ez 6dB3jhHWtVRstUrvr+YIJkmjkuomBWQXMGTWDsJr1kV7DBR7dSXEYFL31 Y=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.01,153,1684792800"; d="scan'208";a="59686185" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2023 23:15:14 +0200 From: Julia Lawall To: Nilesh Javali Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 24/26] scsi: qla2xxx: use array_size Date: Fri, 23 Jun 2023 23:14:55 +0200 Message-Id: <20230623211457.102544-25-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230623211457.102544-1-Julia.Lawall@inria.fr> References: <20230623211457.102544-1-Julia.Lawall@inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/scsi/qla2xxx/qla_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 1a955c3ff3d6..72569ed6c825 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -8219,7 +8219,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr, ql_dbg(ql_dbg_init, vha, 0x0163, "-> fwdt%u template allocate template %#x words...\n", j, risc_size); - fwdt->template = vmalloc(risc_size * sizeof(*dcode)); + fwdt->template = vmalloc(array_size(risc_size, sizeof(*dcode))); if (!fwdt->template) { ql_log(ql_log_warn, vha, 0x0164, "-> fwdt%u failed allocate template.\n", j); @@ -8474,7 +8474,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr) ql_dbg(ql_dbg_init, vha, 0x0173, "-> fwdt%u template allocate template %#x words...\n", j, risc_size); - fwdt->template = vmalloc(risc_size * sizeof(*dcode)); + fwdt->template = vmalloc(array_size(risc_size, sizeof(*dcode))); if (!fwdt->template) { ql_log(ql_log_warn, vha, 0x0174, "-> fwdt%u failed allocate template.\n", j);