summaryrefslogtreecommitdiff
path: root/src/northbridge/amd
diff options
context:
space:
mode:
Diffstat (limited to 'src/northbridge/amd')
-rw-r--r--src/northbridge/amd/amdk8/northbridge.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/northbridge/amd/amdk8/northbridge.c b/src/northbridge/amd/amdk8/northbridge.c
index 63f543e0a0..a17aa65a82 100644
--- a/src/northbridge/amd/amdk8/northbridge.c
+++ b/src/northbridge/amd/amdk8/northbridge.c
@@ -1165,14 +1165,16 @@ static struct device_operations pci_domain_ops = {
static void add_more_links(device_t dev, unsigned total_links)
{
struct bus *link, *last = NULL;
- int link_num;
+ int link_num = -1;
- for (link = dev->link_list; link; link = link->next)
+ for (link = dev->link_list; link; link = link->next) {
+ if (link_num < link->link_num)
+ link_num = link->link_num;
last = link;
+ }
if (last) {
- int links = total_links - last->link_num;
- link_num = last->link_num;
+ int links = total_links - (link_num + 1);
if (links > 0) {
link = malloc(links*sizeof(*link));
if (!link)
@@ -1182,7 +1184,6 @@ static void add_more_links(device_t dev, unsigned total_links)
}
}
else {
- link_num = -1;
link = malloc(total_links*sizeof(*link));
memset(link, 0, total_links*sizeof(*link));
dev->link_list = link;