Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13030219rwd; Fri, 23 Jun 2023 14:36:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4wjv0mFTwBxFCqag3efPnPfP4X411x2KpZ2ij16td9OQ9ta+eJH5wvxOFcv78tERUNnXBt X-Received: by 2002:a05:6358:417:b0:127:f2f6:ef35 with SMTP id 23-20020a056358041700b00127f2f6ef35mr15824275rwd.3.1687556185025; Fri, 23 Jun 2023 14:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556184; cv=none; d=google.com; s=arc-20160816; b=uk/FhHfBfjjE/7g/o6UxnEb74hu51DD+HjaB3IngeEUhaTxl5MnXIx6+JlRGXI3rxG 91K1Xb0TQFRUxx5yNsDNBuzK4dEXmADv4tKLVFQeY+7YmOh6026WypP/pq9Zxq0iUEw8 RvOQbJKiuAEk7wQ5lPTNYb5z9ZlWLHg5S2zTjIgxC+hOdTYWtqGQLpMfV5CcXwy+wULc UkfZcwW0cSeH544WlugPNn+kMRZYGYbCfs0E2Qgp87KstL10dd+73IdFSTitfAbosjHG xtiugTWFUhBD1tTDJW4iwBackSSb4BgZgAW/c5PAsnl6T/89reUJBB+3BlVUrGGWvz/q Yjhw== 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=zjTOkHzHNJN2JwbbSn0B3jYr0f7hFN0oZZoh6lbquOQ=; fh=y0ETFeU6w6trYMg3qM1hoduOKRqZ5aMgSndi/hTfcWA=; b=RgHvQAmg/n9jdYEIxHfIHGFUI0P43D3zRlvygMcARg9KZQmX1phl9BeBRmD3I0mOg4 e94pwGZNQMh5uYBrO7DOqhopfldKMIvc8isgal2Ro16xuV1BYoxMcMaZBhdx3HJki8QI PBX7s7TvvDa5Vjv2w2YB8+jwX7F2GkJ39hPWPVn6QaQ2KETNrTRrtArPBoVLI3OcRq0d Dfv65RB4+A+OIRQnSP9mQMOiqBoszMAQptNpZiuxDjbp+h16fAQXFI0bxUvVhxfAmyoW vqtye7u8sRd+wYiSyMkjYzFAyKZAFzIZASRZ4gOZE5p27NxLDjtKwNwfv4OC47iQabtC /VOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=FPVhggAR; 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 a13-20020a65640d000000b005533c53f3fbsi233849pgv.800.2023.06.23.14.36.12; Fri, 23 Jun 2023 14:36:24 -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=FPVhggAR; 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 S232573AbjFWVRD (ORCPT + 99 others); Fri, 23 Jun 2023 17:17:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232885AbjFWVQk (ORCPT ); Fri, 23 Jun 2023 17:16:40 -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 3D0FB30DE; Fri, 23 Jun 2023 14:15:37 -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=zjTOkHzHNJN2JwbbSn0B3jYr0f7hFN0oZZoh6lbquOQ=; b=FPVhggARCWGLgx/uc1XplQBbZp4QfJ3ScSLfue5dgqmPlrnQ4BiqzZpN IQ21XgRjNNOHEfdPKTVuJdURuqERB5NCaGfeDpyZ+YpyMYSfpq+KUPiuU +vQ3rGawBQbmwNRu052NXLgEaJzd/RusbfLOqx+1C3Tv2tUHQBsR4S4Tk g=; 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="59686190" 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:15 +0200 From: Julia Lawall To: Ian Abbott Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, H Hartley Sweeten , linux-kernel@vger.kernel.org Subject: [PATCH 26/26] comedi: use array_size Date: Fri, 23 Jun 2023 23:14:57 +0200 Message-Id: <20230623211457.102544-27-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: // @@ size_t e1,e2; expression COUNT; identifier alloc = {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) // Signed-off-by: Julia Lawall --- drivers/comedi/comedi_buf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/comedi/comedi_buf.c b/drivers/comedi/comedi_buf.c index 393966c09740..32ad3e6e1ce8 100644 --- a/drivers/comedi/comedi_buf.c +++ b/drivers/comedi/comedi_buf.c @@ -89,7 +89,7 @@ comedi_buf_map_alloc(struct comedi_device *dev, enum dma_data_direction dma_dir, bm->dma_hw_dev = get_device(dev->hw_dev); } - bm->page_list = vzalloc(sizeof(*buf) * n_pages); + bm->page_list = vzalloc(array_size(n_pages, sizeof(*buf))); if (!bm->page_list) goto err; @@ -169,7 +169,7 @@ static void __comedi_buf_alloc(struct comedi_device *dev, buf = &bm->page_list[0]; async->prealloc_buf = buf->virt_addr; } else { - pages = vmalloc(sizeof(struct page *) * n_pages); + pages = vmalloc(array_size(n_pages, sizeof(struct page *))); if (!pages) return;