From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Chenyuan Mi <cymi20@fudan.edu.cn>
Cc: ilpo.jarvinen@linux.intel.com, gregkh@linuxfoundation.org,
jirislaby@kernel.org, linux-serial@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] serial: 8250_lpss: Fix missing check for return value of pci_get_slot()
Date: Wed, 14 Jun 2023 19:08:48 +0300 [thread overview]
Message-ID: <ZInmEJJjLEwCiOBU@smile.fi.intel.com> (raw)
In-Reply-To: <20230614153226.117768-1-cymi20@fudan.edu.cn>
On Wed, Jun 14, 2023 at 08:32:26AM -0700, Chenyuan Mi wrote:
> The pci_get_slot() function may return NULL, which may
> cause null pointer deference, and most other callsites of
> pci_get_slot() do Null check. Add Null check for return
> value of pci_get_slot().
>
> Found by our static analysis tool.
...
> dma_dev = pci_get_slot(pdev->bus, PCI_DEVFN(PCI_SLOT(pdev->devfn), 0));
> + if (!dma_dev)
> + return -ENODEV;
This adds (almost) a dead code. The function 0 must be present in accordance
with the PCI specification (even earliest version of it state that).
If pci_get_slot() returns a NULL, in this case it means that something, much
bigger issue, happens and this check won't help us to do anything anyway.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-06-14 16:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-14 15:32 [PATCH] serial: 8250_lpss: Fix missing check for return value of pci_get_slot() Chenyuan Mi
2023-06-14 16:08 ` Andy Shevchenko [this message]
2023-06-14 16:28 ` Greg KH
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=ZInmEJJjLEwCiOBU@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=cymi20@fudan.edu.cn \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@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