Ingo Molnar
f022bfd582
x86: PAT fix
Adrian Bunk noticed the following Coverity report:
> Commit e7f260a276
> (x86: PAT use reserve free memtype in mmap of /dev/mem)
> added the following gem to arch/x86/mm/pat.c:
>
> <-- snip -->
>
> ...
> int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
> unsigned long size, pgprot_t *vma_prot)
> {
> u64 offset = ((u64) pfn) << PAGE_SHIFT;
> unsigned long flags = _PAGE_CACHE_UC_MINUS;
> unsigned long ret_flags;
> ...
> ... (nothing that touches ret_flags)
> ...
> if (flags != _PAGE_CACHE_UC_MINUS) {
> retval = reserve_memtype(offset, offset + size, flags, NULL);
> } else {
> retval = reserve_memtype(offset, offset + size, -1, &ret_flags);
> }
>
> if (retval < 0)
> return 0;
>
> flags = ret_flags;
>
> if (pfn <= max_pfn_mapped &&
> ioremap_change_attr((unsigned long)__va(offset), size, flags) < 0) {
> free_memtype(offset, offset + size);
> printk(KERN_INFO
> "%s:%d /dev/mem ioremap_change_attr failed %s for %Lx-%Lx\n",
> current->comm, current->pid,
> cattr_name(flags),
> offset, offset + size);
> return 0;
> }
>
> *vma_prot = __pgprot((pgprot_val(*vma_prot) & ~_PAGE_CACHE_MASK) |
> flags);
> return 1;
> }
>
> <-- snip -->
>
> If (flags != _PAGE_CACHE_UC_MINUS) we pass garbage from the stack to
> ioremap_change_attr() and/or __pgprot().
>
> Spotted by the Coverity checker.
the fix simplifies the code as we get rid of the 'ret_flags'
complication.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-04-28 08:15:16 -07:00
..
2008-04-24 08:35:47 -07:00
2008-04-24 08:42:21 -07:00
2008-04-19 20:40:11 -04:00
2008-04-25 08:29:11 +08:00
2008-04-17 10:42:34 -04:00
2008-04-21 16:03:13 -07:00
2008-04-17 10:42:34 -04:00
2008-04-27 18:21:16 +03:00
2008-04-17 10:42:34 -04:00
2008-04-18 22:14:49 -04:00
2008-04-17 10:42:34 -04:00
2008-04-18 22:14:49 -04:00
2008-04-20 21:46:58 -07:00
2008-04-21 15:58:35 -07:00
2008-04-27 18:21:39 +03:00
2008-04-24 20:57:34 +10:00
2008-04-27 18:21:16 +03:00
2008-04-21 15:58:35 -07:00
2008-04-23 23:32:18 -07:00
2008-04-25 03:11:37 -07:00
2008-04-26 19:21:17 +02:00
2008-04-18 22:14:49 -04:00
2008-04-28 08:15:16 -07:00
2008-04-17 10:42:34 -04:00
2008-01-19 21:29:39 -08:00
2008-03-04 16:35:11 -08:00