lkml.org 
[lkml]   [2021]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] PCI: Check value of resource alignment before using __ffs
Date
Return value of __ffs is undefined if no set bit exists in
its argument. This indicates that the associated BAR has
invalid alignment.

Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com>
---
drivers/pci/setup-bus.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 2ce636937c6e..44e8449418ae 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1044,6 +1044,11 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
* resources.
*/
align = pci_resource_alignment(dev, r);
+ if (!align) {
+ pci_warn(dev, "BAR %d: %pR has bogus alignment\n",
+ i, r);
+ continue;
+ }
order = __ffs(align) - 20;
if (order < 0)
order = 0;
--
2.31.1
\
 
 \ /
  Last update: 2021-04-21 20:51    [W:0.059 / U:0.716 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site