Message ID | 20221013175148.617518003@linuxfoundation.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp409984wrs; Thu, 13 Oct 2022 11:05:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74Uij12WAX6vQKffumgTLcBNEGU3ys/L+JMvYswCWV9P5oXS3ZJR+BAKrPK3EvT71IZ/jH X-Received: by 2002:a17:90b:384f:b0:20d:4761:3394 with SMTP id nl15-20020a17090b384f00b0020d47613394mr1149994pjb.144.1665684342427; Thu, 13 Oct 2022 11:05:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684342; cv=none; d=google.com; s=arc-20160816; b=pEaUEzRDyB8R39H+96kxxLysuzHUWE1i6Brud+ZwP5DcMUmXLnkXGCx/KR+f1861zW cG2CtG4ZNejTHX02h0vJPFzgxRDYtvZ28rIfFsMmfY/QtiawY0RntrX5NMUOUJmnhftJ k9CGSrkBf4+4SP/7DfEE+UK5XVbU+P2YYJUnEgx9PqGRR9PE8g89VqYH5Czd05uDqK2h oAlOQIfX0MPGaaGbJqVAOS4JPdCZxAebkIHs8LHEjnVLOQEIrneOTqQMSak90d824Qcb nw2WzoT/GDJ6gXfmlkpfI1jwCnnTiZAi8mDD08a82pjzhnTTRhY9IqMUTTMH/i3pciWv k/sw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZWo06QU3Y7RGTZo6EHOZTu47TVRZ/5ztXMqTtbIEcpM=; b=luDupiRadOPr3W88iYkXi040xKqq3S3jFQFlwRSLzH43Jb25ENndPGbQuZqowKOSWZ 4ENygkv9PVdDLCN1Bc6CqhYkINTGM+WNOddbTkgb849bn1sp/8KKuezJ0rKKlIz+hKWz ICufR5tbuO6JGhXa6gGP7R1Qq66UATzZ3Aei1e2jJekUnjWuHUb5Z50IxrvjdASAGE1u GhebcCdPgslOJnantkaL+zBdLkGYIfux5Wm/BknmdWUI3BlJkC+Lw8ClOZu66501x6cf 5KULE3aifxbjLQ3bjWORVF/e9/per8T1hZjF2AtNdZqCOQV1MzCFM2n49YOa7PWFPiet Lb9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fv9hnyuq; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x186-20020a6386c3000000b004394687b653si71894pgd.253.2022.10.13.11.05.30; Thu, 13 Oct 2022 11:05:42 -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=@linuxfoundation.org header.s=korg header.b=fv9hnyuq; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230160AbiJMSEz (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Thu, 13 Oct 2022 14:04:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230520AbiJMSDX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Oct 2022 14:03:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EA8216F419; Thu, 13 Oct 2022 11:03:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 100B56190E; Thu, 13 Oct 2022 17:56:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B54BC433D6; Thu, 13 Oct 2022 17:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683802; bh=w7/9AVzZ9ndeBeSxC7PHlgXCtfuyzqO6drfGK0LwTx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fv9hnyuq9MgM7J0GaKDYByKCEivL0pS1Ugl2rF/o/iHUKIMxJI4kcHZt6YLqLZuaD 0sr4PS/ZF3oWxz7NZZbN7LRdCNIAvkVp1DtY7McUaDyzCLaSuRKoZHJ4F2zG6Smlk6 i17UhiTRZLoM48fxkuv1H/2s30OgIZ4oHRalKTnI= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, Shunsuke Mie <mie@igel.co.jp>, stable <stable@kernel.org> Subject: [PATCH 5.10 53/54] misc: pci_endpoint_test: Aggregate params checking for xfer Date: Thu, 13 Oct 2022 19:52:47 +0200 Message-Id: <20221013175148.617518003@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175147.337501757@linuxfoundation.org> References: <20221013175147.337501757@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596625322694436?= X-GMAIL-MSGID: =?utf-8?q?1746596625322694436?= |
Series |
None
|
|
Commit Message
Greg KH
Oct. 13, 2022, 5:52 p.m. UTC
From: Shunsuke Mie <mie@igel.co.jp> commit 3e42deaac06567c7e86d287c305ccda24db4ae3d upstream. Each transfer test functions have same parameter checking code. This patch unites those to an introduced function. Signed-off-by: Shunsuke Mie <mie@igel.co.jp> Cc: stable <stable@kernel.org> Link: https://lore.kernel.org/r/20220907020100.122588-1-mie@igel.co.jp Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/misc/pci_endpoint_test.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
--- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -331,6 +331,17 @@ static bool pci_endpoint_test_msi_irq(st return false; } +static int pci_endpoint_test_validate_xfer_params(struct device *dev, + struct pci_endpoint_test_xfer_param *param, size_t alignment) +{ + if (param->size > SIZE_MAX - alignment) { + dev_dbg(dev, "Maximum transfer data size exceeded\n"); + return -EINVAL; + } + + return 0; +} + static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, unsigned long arg) { @@ -362,9 +373,11 @@ static bool pci_endpoint_test_copy(struc return false; } + err = pci_endpoint_test_validate_xfer_params(dev, ¶m, alignment); + if (err) + return false; + size = param.size; - if (size > SIZE_MAX - alignment) - goto err; use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma) @@ -496,9 +509,11 @@ static bool pci_endpoint_test_write(stru return false; } + err = pci_endpoint_test_validate_xfer_params(dev, ¶m, alignment); + if (err) + return false; + size = param.size; - if (size > SIZE_MAX - alignment) - goto err; use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma) @@ -594,9 +609,11 @@ static bool pci_endpoint_test_read(struc return false; } + err = pci_endpoint_test_validate_xfer_params(dev, ¶m, alignment); + if (err) + return false; + size = param.size; - if (size > SIZE_MAX - alignment) - goto err; use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma)