Messages in this thread | | | Date | Sat, 27 Sep 2008 00:16:46 -0700 | From | Jeremy Fitzhardinge <> | Subject | Re: [patch] ioremap sanity check to catch mapping requests exceeding the BAR sizes |
| |
Suresh Siddha wrote: > +int iomem_map_sanity_check(resource_size_t addr, unsigned long size) > +{ > + struct resource *p = &iomem_resource; > + int err = 0; > + loff_t l; > + > + read_lock(&resource_lock); > + for (p = p->child; p ; p = r_next(NULL, p, &l)) { > + /* > + * We can probably skip the resources with out > + * IORESOURCE_IO attribute? >
Any attempt to use ioremap on memory is a bug, so you should warn about that too.
> + */ > + if (p->start >= addr + size) > + continue; > + if (p->end < addr) > + continue; > + if (p->start <= addr && (p->end >= addr + size - 1)) > + continue; > + printk(KERN_WARNING "resource map sanity check conflict " > + " 0x%llx 0x%llx 0x%llx 0x%llx %s\n", > + addr, addr + size - 1, p->start, p->end, p->name); > + err = -1; > + break; > + } > + read_unlock(&resource_lock); > + > + return err;
J
| |