mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Be a bit defensive in quirk_nvidia_ck804() so we don't risk dereferencing a NULL pdev.
@ 2006-12-01 23:21 Jesper Juhl
  2006-12-01 23:55 ` Alan
  2006-12-02  0:59 ` David Rientjes
  0 siblings, 2 replies; 3+ messages in thread
From: Jesper Juhl @ 2006-12-01 23:21 UTC (permalink / raw)
  To: linux-kernel; +Cc: Martin Mares

pci_get_slot() may return NULL if nothing was found. 
quirk_nvidia_ck804() does not check the value returned from pci_get_slot(),
so it may end up causing a NULL pointer deref.


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 drivers/pci/quirks.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 5b44838..d3dcbda 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1741,6 +1741,8 @@ static void __devinit quirk_nvidia_ck804
 	 * a single one having MSI is enough to be sure that MSI are supported.
 	 */
 	pdev = pci_get_slot(dev->bus, 0);
+	if (!pdev)
+		return;
 	if (dev->subordinate && !msi_ht_cap_enabled(dev)
 	    && !msi_ht_cap_enabled(pdev)) {
 		printk(KERN_WARNING "PCI: MSI quirk detected. "



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Be a bit defensive in quirk_nvidia_ck804() so we don't risk dereferencing a NULL pdev.
  2006-12-01 23:21 [PATCH] Be a bit defensive in quirk_nvidia_ck804() so we don't risk dereferencing a NULL pdev Jesper Juhl
@ 2006-12-01 23:55 ` Alan
  2006-12-02  0:59 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: Alan @ 2006-12-01 23:55 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-kernel, Martin Mares

On Sat, 2 Dec 2006 00:21:56 +0100
Jesper Juhl <jesper.juhl@gmail.com> wrote:

> pci_get_slot() may return NULL if nothing was found. 
> quirk_nvidia_ck804() does not check the value returned from pci_get_slot(),
> so it may end up causing a NULL pointer deref.
> 
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>

I don't think its a physically possible case but it does no harm and
it'll kill boot if it happens

Acked-by: Alan Cox <alan@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Be a bit defensive in quirk_nvidia_ck804() so we don't risk dereferencing a NULL pdev.
  2006-12-01 23:21 [PATCH] Be a bit defensive in quirk_nvidia_ck804() so we don't risk dereferencing a NULL pdev Jesper Juhl
  2006-12-01 23:55 ` Alan
@ 2006-12-02  0:59 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2006-12-02  0:59 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-kernel, Martin Mares

On Sat, 2 Dec 2006, Jesper Juhl wrote:

> pci_get_slot() may return NULL if nothing was found. 
> quirk_nvidia_ck804() does not check the value returned from pci_get_slot(),
> so it may end up causing a NULL pointer deref.
> 

Looks good.  The possible NULL pointer is actually not at pci_dev_put, 
but rather at pci_find_capability on the msi_ht_cap_enabled(pdev) call.

> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index 5b44838..d3dcbda 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -1741,6 +1741,8 @@ static void __devinit quirk_nvidia_ck804
>  	 * a single one having MSI is enough to be sure that MSI are supported.
>  	 */
>  	pdev = pci_get_slot(dev->bus, 0);
> +	if (!pdev)
> +		return;
>  	if (dev->subordinate && !msi_ht_cap_enabled(dev)
>  	    && !msi_ht_cap_enabled(pdev)) {
>  		printk(KERN_WARNING "PCI: MSI quirk detected. "
> 

The check for dev->subordinate in the neighboring conditional can also be 
removed.

		David

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-12-02  1:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-01 23:21 [PATCH] Be a bit defensive in quirk_nvidia_ck804() so we don't risk dereferencing a NULL pdev Jesper Juhl
2006-12-01 23:55 ` Alan
2006-12-02  0:59 ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome