Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp612918rwe; Wed, 24 Aug 2022 06:30:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR4syDW+XVrW097YT+4lCNYAatO58bo88RoXz/fN6jfPBNWKfuV/IasORwQn2xCC8t9CQ6F3 X-Received: by 2002:a63:cf44:0:b0:42a:277:1cb8 with SMTP id b4-20020a63cf44000000b0042a02771cb8mr24305205pgj.198.1661347842527; Wed, 24 Aug 2022 06:30:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661347840; cv=none; d=google.com; s=arc-20160816; b=ulcujbRaTo6sC3tjglS4aQ3T+An4YlkN3nHNpvPOPo/fEvs+DyRp7X/+qQOhUGWZkc OS1B/Z2puFohmWwQioAN4YFMNVI3o2WPCmGyvK0oiBI3Rz21uvfDGxVgoa8rAIUTOJ+2 9lnUMHNCuC497kRTAKuKVvJjoDhLRrid4Bk+l6QL+jgwMtPHpsD/sF9+pBqIRNFV2DAK r9EB3MTnf2M99VRNSffssf9PxToRjGfxs50SIBkHbRyqnD8VVQnWT85NtL22hWTuLigH S2yHlBgRZ7n20HryDuR+/2HQZ19HMK0xiSkQEHxEqnQCxyGxGQpVlOvJeLd+AZxMsdpj W+xA== 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=JjldjZREW7xCbMlI8ioBLF6UZ2j0Ph4pQUFRjTNuUig=; b=qkjF+FSBjUPmHLn7SIuD7Ie7vHYp2/tSRNCvDaL6MxqYXKuSrmB898hEb6H0+72RgJ Kk0R+XC3WdApFaFwU4rJLM9QzMXCpoNd/szPs4HnLY7APop3o8WKUMJDdOj9+xOQbRlF zIOJJzuREUYrFBRhLHEcz/GGGVcazQ8r41Jit65ZdLHbIrDVEv5smP/7Vuu8o3VfPmHX g1w2RU4Qko0QHCu7G7wI4Ji1M90OODfJibiL2tjlyiNBQOemKnojXZrvFKJu+MTFpbVq Xnxa0xXUJGql6g+6y1fpZgT1zv13UCsWZcFNmG1NXQjEudImzcUKDEtdkNikIsjpI+7Q mCGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LMQeii5k; 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 a3-20020a1709027e4300b001709c82ca08si16916894pln.297.2022.08.24.06.30.28; Wed, 24 Aug 2022 06:30:39 -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=LMQeii5k; 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 S236929AbiHXMn0 (ORCPT + 99 others); Wed, 24 Aug 2022 08:43:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235074AbiHXMnZ (ORCPT ); Wed, 24 Aug 2022 08:43:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47B1A696C6; Wed, 24 Aug 2022 05:43:24 -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 ams.source.kernel.org (Postfix) with ESMTPS id E49B4B823EE; Wed, 24 Aug 2022 12:43:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 392B9C433C1; Wed, 24 Aug 2022 12:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661345001; bh=eUDEcyDSoKd3iXeAYc6HrNZyJVRX0GLyiR77eO5bfhc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LMQeii5kpZ6oVSzn0mobOeiGb2XIN5zTEyAnYQj5i4fWMsUxN2YjnWXrGulcUiiTV xID+H0L+3ungwiKO6z2C9xKdxYQd9zIRYUaBZuzlPA4nruWKJybzbieQhZQ8aTVxQ6 7OSyIEUmkeXhRpPmBNlL5b5Q8kt28dkne5MDc5lk= Date: Wed, 24 Aug 2022 14:43:18 +0200 From: Greg KH To: Manivannan Sadhasivam Cc: kishon@ti.com, lpieralisi@kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, mie@igel.co.jp, kw@linux.com, stable@vger.kernel.org Subject: Re: [PATCH v2 1/5] misc: pci_endpoint_test: Fix the return value of IOCTL Message-ID: References: <20220824123010.51763-1-manivannan.sadhasivam@linaro.org> <20220824123010.51763-2-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220824123010.51763-2-manivannan.sadhasivam@linaro.org> 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,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 On Wed, Aug 24, 2022 at 06:00:06PM +0530, Manivannan Sadhasivam wrote: > IOCTLs are supposed to return 0 for success and negative error codes for > failure. Currently, this driver is returning 0 for failure and 1 for > success, that's not correct. Hence, fix it! > > Cc: stable@vger.kernel.org #5.10 > Fixes: 2c156ac71c6b ("misc: Add host side PCI driver for PCI test function device") > Signed-off-by: Manivannan Sadhasivam Reported-by: Greg Kroah-Hartman > --- > drivers/misc/pci_endpoint_test.c | 163 ++++++++++++++----------------- > 1 file changed, 76 insertions(+), 87 deletions(-) > > diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c > index 8f786a225dcf..a7d8ae9730f6 100644 > --- a/drivers/misc/pci_endpoint_test.c > +++ b/drivers/misc/pci_endpoint_test.c > @@ -174,13 +174,12 @@ static void pci_endpoint_test_free_irq_vectors(struct pci_endpoint_test *test) > test->irq_type = IRQ_TYPE_UNDEFINED; > } > > -static bool pci_endpoint_test_alloc_irq_vectors(struct pci_endpoint_test *test, > +static int pci_endpoint_test_alloc_irq_vectors(struct pci_endpoint_test *test, > int type) > { > - int irq = -1; > + int irq = -ENOSPC; No need to set this if you: > struct pci_dev *pdev = test->pdev; > struct device *dev = &pdev->dev; > - bool res = true; > > switch (type) { > case IRQ_TYPE_LEGACY: > @@ -202,15 +201,16 @@ static bool pci_endpoint_test_alloc_irq_vectors(struct pci_endpoint_test *test, > dev_err(dev, "Invalid IRQ type selected\n"); This should now return -EINVAL; > } > > + test->irq_type = type; Again, do not make a change to the kernel state if there is an error above. That's wrong to do, and yes, the current code is incorrect, don't keep that bug here as well when it's so easy to fix up automatically. I stopped reviewing here... thanks, greg k-h