From patchwork Fri Jun 23 21:14:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6048652vqr; Fri, 23 Jun 2023 14:24:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6QzkzsqfnV70avrLBU2vfiBIxbK8Ep6+yItl7AX8KkPzp5UL1d3BfcgxDeJSh7/G7N42/1 X-Received: by 2002:a05:6a21:900c:b0:106:25b3:2f92 with SMTP id tq12-20020a056a21900c00b0010625b32f92mr14662360pzb.52.1687555479817; Fri, 23 Jun 2023 14:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555479; cv=none; d=google.com; s=arc-20160816; b=M0S5nPS8gm3MOI73qJq6X0ragOvbafuoZNZBOvowR0nPHMseJzI/Ur69uPA43n3GEI iNVcb4uzG11nkElHrPavX0cEgCZbAaQhwTlM91SYJ7ya7FPvEUydKzKVqOlLH/NbEDQO VAn4OfKKuS+qOAmDu8TKT9llid2K4CY4lM3fY3VyleZPk2ae8Tbkg1vXPBBkLEjm5rzB dHz0ET7pWgFMi9ALBmk64jQiVg7B6i3y0dY49gM+D+hs0t7cy9lk9ot+p0m9ei9yjoVb U3wuPLcJL+15ibvj/+CPtFOT/2i80cbRX1+Iwb0Bu23W/6J9ZlZEIVO+hQd3clPrxnyb kjew== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k17-20020a056a00135100b00653c0edfd34si46346pfu.139.2023.06.23.14.24.25; Fri, 23 Jun 2023 14:24:39 -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 S232521AbjFWVQp (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:45 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530174603900768?= X-GMAIL-MSGID: =?utf-8?q?1769530174603900768?= 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);