Received: by 10.192.165.156 with SMTP id m28csp137228imm; Tue, 10 Apr 2018 18:15:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx49oCbVoIygXHV+YfCzsWq61/8gnZD3RmBCvDYfMtUulmsU69+LwSHgb7d3ABtO8Pi7bChUW X-Received: by 10.99.125.75 with SMTP id m11mr1848022pgn.391.1523409330202; Tue, 10 Apr 2018 18:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523409330; cv=none; d=google.com; s=arc-20160816; b=cb1VwYosAAD/1ipYk2gSNtCuYppMFWchlwpskR8S2sLWFmtUYZA9KmxMw6JtB7vRw7 Mj6KH0KCiTSYOdtvH8dJWfvH/JadR7pWhwG2T3k3XLznQCsRYC2PNKZA9CJP8Z+fnleF H/egfLCz+OjJQ//qcH8tE1OeE06ac4JfEDbKcHBHajd4pDJowIcIg/b9A4XH8s+84dmJ 7IcrK4EjPoflM0UXtzKNb0BOixQEFGsDNqknlQCVE/mwumKl61BDSYBHjGOjPplOEVj/ H/aQAuAAFENB3qCS3sgReZjNDR8sTz2lw7VsaXWbhLTE3FgfixMmMhuz+QOAN1qVUXjF F2ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=O8WfciiDYl7Lhr+NJARHFTMcRAkCHWWB76RpECIFM0U=; b=PI+7gNjb5l5gjid477S3OIjSCg9PtmEzABPw5/E5v24zeIoOPtlPBtgFt4UxAVxKhy nxYzp19CdYGLLSxVGsmjxOXt9kIpc38+7mVc27bX293tWUeoM3E0XaXb8w/Szz43O/bO 810J/Tz3XnYyHT2fm5Be10sSqd6+hA5k7Ov2FsNKIXa7UWNo3Fg50fZKIg6go1uaqhOr 0uTF8xN9CrompbhHEI3J5Gv+UgQo06ZBL0fd+PwODriO7LkkphibYzpq3bKTug2lK8kI ggC9v3QsVwgOFdVoYZbjLpq4VzhVYEEOtbX7yL6zfY2FYKWhNa/0TLH7EfPKYlwd6BeB mf5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o32-v6si3856294pld.320.2018.04.10.18.14.52; Tue, 10 Apr 2018 18:15:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752906AbeDKBCd (ORCPT + 99 others); Tue, 10 Apr 2018 21:02:33 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:46828 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751775AbeDKBCb (ORCPT ); Tue, 10 Apr 2018 21:02:31 -0400 Received: by mail-pl0-f66.google.com with SMTP id 59-v6so113078plc.13 for ; Tue, 10 Apr 2018 18:02:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=O8WfciiDYl7Lhr+NJARHFTMcRAkCHWWB76RpECIFM0U=; b=my/nft4bLj/H45LbhzwZ2dH0Ez0J2MM2T0kpAFlNZkCd8dgHTipkIbee0mnQhJ6dLa 40MkdcRzXlEMUfs2Css8pNfhEZOw5QsPMkKBKrGqKgLqvrlCIWpu1HU806D8OAlxh/dv o1sSnpYMS8De2a0WiBwrIzTXcC6guXOFKfTbFoCfhsqp3TljGHO7rk3VP/+tl0t8svbA wyC/X9pDB1hByNsxR+8AEuWNjn57nZfP6+xVoEfRerSGmNVEE9xIX7sqiPxkyX5+qvdm llVqe6meLbQig7IWoqoOp+6QmTwotpyOKFDnUFdI2rCL8z+ypIeoMicOs3DWGhorPzXk My9A== X-Gm-Message-State: ALQs6tDQuvSMuHoTEklauuCJKnBHsH7L/KRN0hkKGafYlbTj8DczDArj e42Eq6DhoXiQP1LJsVle6YEa5A== X-Received: by 2002:a17:902:8b84:: with SMTP id ay4-v6mr2665172plb.57.1523408551380; Tue, 10 Apr 2018 18:02:31 -0700 (PDT) Received: from labbott-redhat.redhat.com ([2601:602:9802:a8dc:4eb2:6dae:ab32:e5b0]) by smtp.gmail.com with ESMTPSA id w16sm9504482pfk.125.2018.04.10.18.02.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Apr 2018 18:02:30 -0700 (PDT) From: Laura Abbott To: Vinod Koul , Dan Williams Cc: Laura Abbott , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Kees Cook , Sinan Kaya Subject: [PATCHv2] dmaengine: dmatest: Remove use of VLAs Date: Tue, 10 Apr 2018 18:02:16 -0700 Message-Id: <20180411010216.17702-1-labbott@redhat.com> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There's an ongoing effort to remove VLAs from the kernel (https://lkml.org/lkml/2018/3/7/621) to eventually turn on -Wvla. The test already pre-allocates some buffers with kmalloc so turn the two VLAs in to pre-allocated kmalloc buffers. Signed-off-by: Laura Abbott --- v2: Switch to using kmalloc buffers instead of putting a large array on the stack. --- drivers/dma/dmatest.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 80cc2be6483c..9730956dfbe3 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -463,6 +463,8 @@ static int dmatest_func(void *data) unsigned long long total_len = 0; u8 align = 0; bool is_memset = false; + dma_addr_t *srcs; + dma_addr_t *dma_pq; set_freezable(); @@ -546,6 +548,14 @@ static int dmatest_func(void *data) set_user_nice(current, 10); + srcs = kcalloc(src_cnt, sizeof(dma_addr_t), GFP_KERNEL); + if (!srcs) + goto err_dstbuf; + + dma_pq = kcalloc(dst_cnt, sizeof(dma_addr_t), GFP_KERNEL); + if (!dma_pq) + goto err_srcs_array; + /* * src and dst buffers are freed by ourselves below */ @@ -556,7 +566,6 @@ static int dmatest_func(void *data) && !(params->iterations && total_tests >= params->iterations)) { struct dma_async_tx_descriptor *tx = NULL; struct dmaengine_unmap_data *um; - dma_addr_t srcs[src_cnt]; dma_addr_t *dsts; unsigned int src_off, dst_off, len; @@ -669,8 +678,6 @@ static int dmatest_func(void *data) srcs, src_cnt, len, flags); else if (thread->type == DMA_PQ) { - dma_addr_t dma_pq[dst_cnt]; - for (i = 0; i < dst_cnt; i++) dma_pq[i] = dsts[i] + dst_off; tx = dev->device_prep_dma_pq(chan, dma_pq, srcs, @@ -772,6 +779,9 @@ static int dmatest_func(void *data) runtime = ktime_to_us(ktime); ret = 0; + kfree(dma_pq); +err_srcs_array: + kfree(srcs); err_dstbuf: for (i = 0; thread->udsts[i]; i++) kfree(thread->udsts[i]); -- 2.14.3