* [PATCH] PCI: Improve __pci_read_base robustness
@ 2017-04-10 17:46 Marc Gonzalez
2017-04-18 19:12 ` Bjorn Helgaas
0 siblings, 1 reply; 2+ messages in thread
From: Marc Gonzalez @ 2017-04-10 17:46 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci
Cc: Robin Murphy, Lorenzo Pieralisi, Liviu Dudau, David Laight,
Arnd Bergmann, Thibaud Cornic, Mason, Yinghai Lu, LKML
Local variables 'l' and 'sz' are uninitialized. Normally, they would
be initialized by pci_read_config_dword() but when an error occurs,
some drivers immediately return an error code, which leaves the
argument uninitialized.
Provide a safe initial value to make the code more robust.
Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
---
drivers/pci/probe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index d266d800f246..6fb929bd7040 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -175,7 +175,7 @@ static inline unsigned long decode_bar(struct pci_dev *dev, u32 bar)
int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
struct resource *res, unsigned int pos)
{
- u32 l, sz, mask;
+ u32 l = 0, sz = 0, mask;
u64 l64, sz64, mask64;
u16 orig_cmd;
struct pci_bus_region region, inverted_region;
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI: Improve __pci_read_base robustness
2017-04-10 17:46 [PATCH] PCI: Improve __pci_read_base robustness Marc Gonzalez
@ 2017-04-18 19:12 ` Bjorn Helgaas
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2017-04-18 19:12 UTC (permalink / raw)
To: Marc Gonzalez
Cc: linux-pci, Robin Murphy, Lorenzo Pieralisi, Liviu Dudau,
David Laight, Arnd Bergmann, Thibaud Cornic, Mason, Yinghai Lu,
LKML
On Mon, Apr 10, 2017 at 07:46:54PM +0200, Marc Gonzalez wrote:
> Local variables 'l' and 'sz' are uninitialized. Normally, they would
> be initialized by pci_read_config_dword() but when an error occurs,
> some drivers immediately return an error code, which leaves the
> argument uninitialized.
>
> Provide a safe initial value to make the code more robust.
>
> Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Applied to pci/enumeration for v4.12, thanks!
> ---
> drivers/pci/probe.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index d266d800f246..6fb929bd7040 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -175,7 +175,7 @@ static inline unsigned long decode_bar(struct pci_dev *dev, u32 bar)
> int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
> struct resource *res, unsigned int pos)
> {
> - u32 l, sz, mask;
> + u32 l = 0, sz = 0, mask;
> u64 l64, sz64, mask64;
> u16 orig_cmd;
> struct pci_bus_region region, inverted_region;
> --
> 2.11.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-18 19:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-10 17:46 [PATCH] PCI: Improve __pci_read_base robustness Marc Gonzalez
2017-04-18 19:12 ` Bjorn Helgaas
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.