All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/msi: Don't dereference pdev before its NULL check
@ 2015-07-23 10:54 Andrew Cooper
  2015-07-23 11:45 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2015-07-23 10:54 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Jan Beulich

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/arch/x86/msi.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c
index fa95048..160167c 100644
--- a/xen/arch/x86/msi.c
+++ b/xen/arch/x86/msi.c
@@ -1345,7 +1345,7 @@ int pci_restore_msi_state(struct pci_dev *pdev)
     struct msi_desc *entry, *tmp;
     struct irq_desc *desc;
     struct msi_msg msg;
-    u8 slot = PCI_SLOT(pdev->devfn), func = PCI_FUNC(pdev->devfn);
+    u8 slot, func;
     unsigned int type = 0, pos = 0;
     u16 control = 0;
 
@@ -1357,6 +1357,9 @@ int pci_restore_msi_state(struct pci_dev *pdev)
     if ( !pdev )
         return -EINVAL;
 
+    slot = PCI_SLOT(pdev->devfn);
+    func = PCI_FUNC(pdev->devfn);
+
     ret = xsm_resource_setup_pci(XSM_PRIV,
                                 (pdev->seg << 16) | (pdev->bus << 8) |
                                 pdev->devfn);
-- 
1.7.10.4

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

* Re: [PATCH] x86/msi: Don't dereference pdev before its NULL check
  2015-07-23 10:54 [PATCH] x86/msi: Don't dereference pdev before its NULL check Andrew Cooper
@ 2015-07-23 11:45 ` Jan Beulich
  2015-07-23 11:57   ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2015-07-23 11:45 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Xen-devel

>>> On 23.07.15 at 12:54, <andrew.cooper3@citrix.com> wrote:
> --- a/xen/arch/x86/msi.c
> +++ b/xen/arch/x86/msi.c
> @@ -1345,7 +1345,7 @@ int pci_restore_msi_state(struct pci_dev *pdev)
>      struct msi_desc *entry, *tmp;
>      struct irq_desc *desc;
>      struct msi_msg msg;
> -    u8 slot = PCI_SLOT(pdev->devfn), func = PCI_FUNC(pdev->devfn);
> +    u8 slot, func;
>      unsigned int type = 0, pos = 0;
>      u16 control = 0;
>  
> @@ -1357,6 +1357,9 @@ int pci_restore_msi_state(struct pci_dev *pdev)
>      if ( !pdev )
>          return -EINVAL;
>  
> +    slot = PCI_SLOT(pdev->devfn);
> +    func = PCI_FUNC(pdev->devfn);

I think this is the wrong way round - see the alternative patch just
sent.

Btw, how did you spot this so quickly now but not during review?
Any tool helping with that?

Jan

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

* Re: [PATCH] x86/msi: Don't dereference pdev before its NULL check
  2015-07-23 11:45 ` Jan Beulich
@ 2015-07-23 11:57   ` Andrew Cooper
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2015-07-23 11:57 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Xen-devel

On 23/07/15 12:45, Jan Beulich wrote:
>>>> On 23.07.15 at 12:54, <andrew.cooper3@citrix.com> wrote:
>> --- a/xen/arch/x86/msi.c
>> +++ b/xen/arch/x86/msi.c
>> @@ -1345,7 +1345,7 @@ int pci_restore_msi_state(struct pci_dev *pdev)
>>      struct msi_desc *entry, *tmp;
>>      struct irq_desc *desc;
>>      struct msi_msg msg;
>> -    u8 slot = PCI_SLOT(pdev->devfn), func = PCI_FUNC(pdev->devfn);
>> +    u8 slot, func;
>>      unsigned int type = 0, pos = 0;
>>      u16 control = 0;
>>  
>> @@ -1357,6 +1357,9 @@ int pci_restore_msi_state(struct pci_dev *pdev)
>>      if ( !pdev )
>>          return -EINVAL;
>>  
>> +    slot = PCI_SLOT(pdev->devfn);
>> +    func = PCI_FUNC(pdev->devfn);
> I think this is the wrong way round - see the alternative patch just
> sent.
>
> Btw, how did you spot this so quickly now but not during review?
> Any tool helping with that?

Ah - I accidentally neglected to say that it was Coverity.  It is hooked
automatically into all XenServer builds, and I am being proactive
keeping my upstream branch up-to-date, given the volume of code going in
at the moment.

~Andrew

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

end of thread, other threads:[~2015-07-23 11:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-23 10:54 [PATCH] x86/msi: Don't dereference pdev before its NULL check Andrew Cooper
2015-07-23 11:45 ` Jan Beulich
2015-07-23 11:57   ` Andrew Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.