x86/msi: Don't dereference pdev before its NULL check
PATCH 1/1 x86/msi: Don't dereference pdev before its NULL check
--- xen/arch/x86/msi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
xen/arch/x86/msi.c +4 -1
@@ -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);
Signature · 1 line
1.7.10.4
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 23.07.15 at 12:54, <[email protected]> wrote:
xen/arch/x86/msi.c +1
-1@@ -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 ;
xen/arch/x86/msi.c int pci_restore_msi_state(struct pci_dev *pdev) · line 1361
Quoted 5 lines
xen/arch/x86/msi.c +2
-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
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 23.07.15 at 12:54, <[email protected]> wrote:
xen/arch/x86/msi.c +1
-1@@ -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 ;
Quoted 7 lines
xen/arch/x86/msi.c int pci_restore_msi_state(struct pci_dev *pdev) · line 1361
Quoted 2 lines
xen/arch/x86/msi.c +2
-0+ 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