linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
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
Date: Wed, 24 Aug 2022 14:43:18 +0200	[thread overview]
Message-ID: <YwYc5kcdv+5RQDsK@kroah.com> (raw)
In-Reply-To: <20220824123010.51763-2-manivannan.sadhasivam@linaro.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 <manivannan.sadhasivam@linaro.org>

Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

> ---
>  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

  reply	other threads:[~2022-08-24 12:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-24 12:30 [PATCH v2 0/5] pci_endpoint_test: Fix the return value of IOCTLs Manivannan Sadhasivam
2022-08-24 12:30 ` [PATCH v2 1/5] misc: pci_endpoint_test: Fix the return value of IOCTL Manivannan Sadhasivam
2022-08-24 12:43   ` Greg KH [this message]
2022-08-24 14:25     ` Manivannan Sadhasivam
2022-08-24 12:30 ` [PATCH v2 2/5] tools: PCI: Fix parsing the return value of IOCTLs Manivannan Sadhasivam
2022-08-24 12:44   ` Greg KH
2022-08-24 14:28     ` Manivannan Sadhasivam
2022-11-01 14:15     ` Manivannan Sadhasivam
2022-11-01 17:11       ` Greg KH
2022-08-24 12:30 ` [PATCH v2 3/5] Documentation: PCI: endpoint: Use the correct return value of pcitest.sh Manivannan Sadhasivam
2022-08-24 12:30 ` [PATCH v2 4/5] misc: pci_endpoint_test: Remove unnecessary WARN_ON Manivannan Sadhasivam
2022-08-24 12:30 ` [PATCH v2 5/5] tools: PCI: Fix memory leak Manivannan Sadhasivam
2022-09-09 13:09 ` [PATCH v2 0/5] pci_endpoint_test: Fix the return value of IOCTLs Lorenzo Pieralisi
2022-11-01 14:03   ` Manivannan Sadhasivam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YwYc5kcdv+5RQDsK@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=kishon@ti.com \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=mie@igel.co.jp \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).