PCI: mvebu: Fix uninitialized variable in mvebu_get_tgt_attr()
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Wed, 17 Sep 2014 15:58:27 +0000 (17:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Oct 2014 16:38:23 +0000 (09:38 -0700)
commit1ed8711eab1de778174bba04464ac94860403792
tree38a593d58e6687c0bb7ab62d63bb2dda3d9da25c
parentdb2dccfee50de21a0d4c8ca7b215bf4d50a27335
PCI: mvebu: Fix uninitialized variable in mvebu_get_tgt_attr()

commit 56fab6e189441d714a2bfc8a64f3df9c0749dff7 upstream.

Geert Uytterhoeven reported a warning when building pci-mvebu:

  drivers/pci/host/pci-mvebu.c: In function 'mvebu_get_tgt_attr':
  drivers/pci/host/pci-mvebu.c:887:39: warning: 'rtype' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (slot == PCI_SLOT(devfn) && type == rtype) {
 ^

And indeed, the code of mvebu_get_tgt_attr() may lead to the usage of rtype
when being uninitialized, even though it would only happen if we had
entries other than I/O space and 32 bits memory space.

This commit fixes that by simply skipping the current DT range being
considered, if it doesn't match the resource type we're looking for.

Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pci/host/pci-mvebu.c