From patchwork Thu Nov 1 16:07:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10664199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12E3017DB for ; Thu, 1 Nov 2018 16:07:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 028332C076 for ; Thu, 1 Nov 2018 16:07:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAE562C079; Thu, 1 Nov 2018 16:07:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 503362C076 for ; Thu, 1 Nov 2018 16:07:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728239AbeKBBLH (ORCPT ); Thu, 1 Nov 2018 21:11:07 -0400 Received: from mail-eopbgr720053.outbound.protection.outlook.com ([40.107.72.53]:29604 "EHLO NAM05-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728078AbeKBBLG (ORCPT ); Thu, 1 Nov 2018 21:11:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1BZ1AJOiOr6adlmNcPDoyrfIXhjAE3iflo8lJQ5RZFU=; b=cQ0LV3DF7H9r+xqkkGhKz5x5MfyPnWpf/YpxFSjVVPDO5hy7hbCgFKVlgLhbnzXBw9l0e9ggMyNxDhtvlc1NoQ6dQRVuERZZUkcK4IUBOWrfxts9mTL0iEPY6Y2CjgipZoe1TYkYAEjOOnJpFzzZkCv7UhX9nwmRJ5i/7ixPK00= Received: from MWHPR03CA0044.namprd03.prod.outlook.com (2603:10b6:301:3b::33) by BY1PR0301MB1223.namprd03.prod.outlook.com (2a01:111:e400:510f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.27; Thu, 1 Nov 2018 16:07:26 +0000 Received: from BN1AFFO11FD013.protection.gbl (2a01:111:f400:7c10::147) by MWHPR03CA0044.outlook.office365.com (2603:10b6:301:3b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1294.22 via Frontend Transport; Thu, 1 Nov 2018 16:07:26 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BN1AFFO11FD013.mail.protection.outlook.com (10.58.52.73) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1294.14 via Frontend Transport; Thu, 1 Nov 2018 16:07:25 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id wA1G7PYt030867 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Thu, 1 Nov 2018 09:07:25 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.301.0; Thu, 1 Nov 2018 12:07:24 -0400 Received: from saturn.analog.com ([10.50.1.244]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id wA1G7Ntv030085; Thu, 1 Nov 2018 12:07:24 -0400 From: Alexandru Ardelean To: , CC: Alexandru Ardelean Subject: [PATCH] dmaengine: dmatest: move size checks earlier in function Date: Thu, 1 Nov 2018 18:07:16 +0200 Message-ID: <20181101160716.16352-1-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(396003)(376002)(39860400002)(136003)(2980300002)(438002)(189003)(199004)(356004)(6666004)(478600001)(5660300001)(2906002)(575784001)(86362001)(44832011)(50466002)(110136005)(4326008)(7696005)(51416003)(7636002)(305945005)(426003)(106002)(2616005)(476003)(486006)(126002)(1076002)(1857600001)(8676002)(53416004)(26005)(47776003)(77096007)(336012)(186003)(246002)(106466001)(48376002)(36756003)(50226002)(16586007)(8936002)(316002)(107886003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0301MB1223;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD013;1:cHFOOztX+I4qr4gn809DQFufBurOU+t6hAVHAJaFe3CroxdyCCY8NA6Nm+3BnZl8i2XZqIC9NC2iCbzWC7FvktsvfmQs8MZ4zv6K4hQDGzFO1VxuZZu63B1VBRwGp6sK X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6a46b023-c1fb-4f57-e96a-08d640141da5 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:BY1PR0301MB1223; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1223;3:ILG9se30AFcXkOxzNq0IySpiYwjWLPedZ2xiGV6txb6w7JYFmmINDfNlJGHIMvlAywpoTJldXYIFMvPIlwvlNesNAAdrQSItAipt3VfX+p/2a584fmcT3uZZ1CNXDWxyIjZ4ZXKlzHzmey356Wj+xbcZvK7AP2Tv/ryJzOvXn4uLaMxt3xpC/0PQPjRD5gRQOjEn33r2WM8hxjmwELJ+Jg1jaFNX0fGBsQE+2fhJEJAcBLUwuaXSXXYIWijNrV+1Tnc74JREJOLP+ze/d/jKdZAsKn8B/QTfIBemIV1Ant0EeJ5xA+C9DvWAyS6mqLAX0GqJHVMiQ0fPyfMDLEftt8qUA9Tb6GL39URkHigh11g=;25:n0mnk64aBf1t8Rk9IUnMey7SMdgdEQQgDvOYSs1bma3a7ssFMtnw+6FJ3td0HaadtyLJBOufbYvNU7v5iYsZQctRMu5ASwDZZjuIthSOHiScHaByD5pGZ3qrMLLerDNtu3cf1Fe6D9/t24q/N+X0DM+F/BXKu6L+Sr/EJN3YXw7fcPFzqONi1GnIv5MXAQBQ80wRkyQpXnp+u4aU+06KzQyjb/olQN82BCSK1vgt6De9rrLew3PLeiIUSha9oPCgrK4ZA7rFLalfSQhnI9eFjDW910nUkKvKx7DeeJ9EsehfpZZfuMB+Fzpap/ABEK2r73l+3jNUEd5GpXAL+Yan9w== X-MS-TrafficTypeDiagnostic: BY1PR0301MB1223: X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1223;31:0AgfC0ueAVA7Ehx7uHCqPaKr0GKxiN5PcgcNOEu8LKB7BJjnCwyv82MV+Uv4+10vz9xxZkILhPxq0DHzFRnh8Tivi6ZS/82wr+bAe0T+rjXz7wErqAoW9hnHskqDr0A9WLjp70W1sobMzPwq8+Dwtd79lDMO6DeTWpuj7rN2UJxFpkOsKlSxtNz/pAoFJ5lSOZdQo5yLChkxEvwslfJR3IPsmTEyB1dU80v2wGvPfQc=;20:WnbtOF1cG9a6oQdhdaJzwJBVkVchFhVa8eW0K+uR5EpyL47AM+lYM43y1XA8t+bOVJHdIiKguzBJcfR5PgXIBq+1vdjEYw9eD/WakjpWOQIbm3Jg16ENJDyVDRUXzI1Vu633J1xHVfS8WK7Kpf8ywC/+y4sGWhAHy7j4N6t2WuNB+1Yo4ZG4MxM4Lsf1CsMLZYymqN0M8tV3s2n1VF92kHY2tPBoSEVBOgbKkBYiJ+LC6eBBWRx1vR8Uqo25njB0Oq8hw1O49MCjrdNrVz4/E+KXrUk2OF2RHpv4GPH9p+NHNYNG/gZI7aHfaKS+gq7g2nX9emFEazpOEXur2pye8LRixOQPqTXpIh+4qsPDTFmuSSf2PihctkMZ0BVHrCSL/KUxhG/JAEqXDYuZ9X+FmS+7B+4bDBP76Qh9u/1F9BYMHWQUoBeav8+fxJ3tgnJ8872C9jEm/hSnEDGlzBHhDJ0tSBepjVdwUyFnkGyKrJXhLBLDePyYyOyQc50AgAGq X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(232431446821674); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93004095)(3231382)(944501410)(52105095)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699051)(76991095);SRVR:BY1PR0301MB1223;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB1223; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1223;4:5vqD1df4PBmQSRMDJS++JIG3nU4VmYulj8kbFnDyMt3472Ef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e2qZSXXcNFTCF+2FsEb3VmiOZRm+ScxI0mTdKR2D5fykQFfwML1CUYaTnb94LC/ha6X5Jc+Oi8vdhz7q9IRLO8VU+haJotz6aAUp699c3eE/5GwpwjhgzAAYlp2xTOiHcQ3w==;5:+QWmdIfFlvZO+zR+LN0SM2sXhuqANYoGxgZpaFzwZoeb5PkH1PmEj4xZLK92YpvsOxCk9wNrMq2TKTXOd7YDLFOoT4tU/Uv5SWP4Vc9hCTjE8R9lTxNavqDOB+8u4M02rtIIw2hv1FfXhZygugSWZ/jeQ9NAdLL29RzZjF4pg04=;7:HLCo9bWoThhKdpiZfBr0kAp+rGkBn4TJest7q8sSseq7Tsmn4c5EVoOhJKepUC+UUEqOIXc+bnjPGjqQI4ZPLrGjribBMXtdkiopgVD64p9zookTjOIn6uenqEpjyY6LmLJ8wqZqOHwJP2vJ4LOK6A== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2018 16:07:25.9346 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a46b023-c1fb-4f57-e96a-08d640141da5 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0301MB1223 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's no need to allocate all that memory if these sizes are invalid anyway. Signed-off-by: Alexandru Ardelean --- drivers/dma/dmatest.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index aa1712beb0cc..fa991e095ef2 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -507,6 +507,19 @@ static int dmatest_func(void *data) } else goto err_thread_type; + /* Check if buffer count fits into map count variable (u8) */ + if ((src_cnt + dst_cnt) >= 255) { + pr_err("too many buffers (%d of 255 supported)\n", + src_cnt + dst_cnt); + goto err_thread_type; + } + + if (1 << align > params->buf_size) { + pr_err("%u-byte buffer too small for %d-byte alignment\n", + params->buf_size, 1 << align); + goto err_thread_type; + } + thread->srcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL); if (!thread->srcs) goto err_srcs; @@ -576,19 +589,6 @@ static int dmatest_func(void *data) total_tests++; - /* Check if buffer count fits into map count variable (u8) */ - if ((src_cnt + dst_cnt) >= 255) { - pr_err("too many buffers (%d of 255 supported)\n", - src_cnt + dst_cnt); - break; - } - - if (1 << align > params->buf_size) { - pr_err("%u-byte buffer too small for %d-byte alignment\n", - params->buf_size, 1 << align); - break; - } - if (params->norandom) len = params->buf_size; else