Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4188339rwb; Tue, 6 Sep 2022 04:05:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR71Wkt1d5b2VdygHgsblLnIZzvd12QVZXZLexNsILN4+EuC3VFJuhq9oEArrVy+izneT569 X-Received: by 2002:a17:906:845c:b0:730:bbf1:196a with SMTP id e28-20020a170906845c00b00730bbf1196amr39929077ejy.13.1662462320811; Tue, 06 Sep 2022 04:05:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662462320; cv=none; d=google.com; s=arc-20160816; b=ycxLcJtYc4OkZv4wIOwK2sGJvqJOy83rhhm2dN0Tpt613pl6I6U9o/hknbTPwsvj+2 yU/FOTGI51bovgmsjVsyrfCDhXYoHDmdBHJHZNqfTB19FIoTBrLNWJR85MrLvQhETnt9 mnarIke51CJ78EN0FRkrGxqSRJ5cmVxg0+F5npZDAVLbsAr0jjuQtVPQMzU5n/vWQxsT jV46y+wpMDU8IfJlmpEvQQg2TxtBtTu6vk0d+kYC+jvo5bm4c4i2K9rtn4/SeIlhHAT4 n5+XG8mgnlv2st8E9Wy2pGshMVacr5R/hjowVButIzBHFbonlG06s4WXC8/Rq2tRQUvp inEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=b5At0GiEvy+3q8a1XWlfzYdOYHoJY1sAINwtPEEdTNg=; b=Xosavk6+GNc4qQKWmc2c/gasNvz1BKzpTNvvep9oRjHXk9pk08nWPTgHMNGBVPJVWO l0X3QePySuyEIPEo9uP+syzpuI79Mo+EH2/1/y3sKc+akV5OcFjuSqjuqmy4ZUnAcr4k g+Be/KCV+wMcg/aLuierancJuERHJS4HjV5OFlzFFmlNgcqiSlY/Z9N7JwJTNdOlM6jq d8rYDmIxeZPLnbNgbGocSiD2wU1VisGW+YFAVy67gGOB23359wwzmpRV0QO3L1MXSIjS aBOosEk/jfpFG4NCTL4sR5gXmmUVg8G2hr/9kLXXFumKiRHrZLDoxkGT1/BGiiekk9rP oQuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2dOoEt4i; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he44-20020a1709073dac00b00718d0604af4si9142352ejc.604.2022.09.06.04.04.54; Tue, 06 Sep 2022 04:05:20 -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=2dOoEt4i; 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 S239673AbiIFK6x (ORCPT + 99 others); Tue, 6 Sep 2022 06:58:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239813AbiIFK6q (ORCPT ); Tue, 6 Sep 2022 06:58:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0229033E3D; Tue, 6 Sep 2022 03:58:44 -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 924C4614AE; Tue, 6 Sep 2022 10:58:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A253AC433C1; Tue, 6 Sep 2022 10:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662461923; bh=1UMB8q0W6BOfIZiB0QLIijgd1VBIsHWeMGabnordQp8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=2dOoEt4io1CvjY0VplDDDiUd9bdCxRAX2hjjOWg2FI457jIaJBRBvhQWqqkOQ+yk7 NjLWNyelXkOTPOGK42YrWSDus6S2AN+I6fN4ECdLG+y/OPvMaeDwA1gxhN4M6MNTUd qrzM6TI/coB3HUn69GOPdBsULGGLTEtXbfC3d5AE= Date: Tue, 6 Sep 2022 12:58:40 +0200 From: Greg Kroah-Hartman To: Shunsuke Mie Cc: Kishon Vijay Abraham I , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Arnd Bergmann , Dan Carpenter , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2 1/2] misc: pci_endpoint_test: Aggregate params checking for xfer Message-ID: References: <20220906101555.106033-1-mie@igel.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220906101555.106033-1-mie@igel.co.jp> 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,T_SCC_BODY_TEXT_LINE 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 On Tue, Sep 06, 2022 at 07:15:54PM +0900, Shunsuke Mie wrote: > Each transfer test functions have same parameter checking code. This patch > unites those to an introduced function. > > Signed-off-by: Shunsuke Mie > --- > Changes in v2: > * New patch > --- > --- > drivers/misc/pci_endpoint_test.c | 35 ++++++++++++++++++++++++++------ > 1 file changed, 29 insertions(+), 6 deletions(-) > > diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c > index 8f786a225dcf..3bd9f135cdac 100644 > --- a/drivers/misc/pci_endpoint_test.c > +++ b/drivers/misc/pci_endpoint_test.c > @@ -332,6 +332,17 @@ static bool pci_endpoint_test_msi_irq(struct pci_endpoint_test *test, > 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_err(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) > { > @@ -363,9 +374,13 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, > return false; > } > > + err = pci_endpoint_test_validate_xfer_params(dev, ¶m, alignment); > + if (err) { > + dev_err(dev, "Invalid parameter\n"); Also, you just printed 2 errors for the same error. Not needed.