From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [ 39/42] vm: convert mtdchar mmap to vm_iomap_memory() helper
Date: Tue, 23 Apr 2013 14:52:37 -0700 [thread overview]
Message-ID: <20130423215209.434735929@linuxfoundation.org> (raw)
In-Reply-To: <20130423215205.523980967@linuxfoundation.org>
3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <torvalds@linux-foundation.org>
commit 8558e4a26b00225efeb085725bc319f91201b239 upstream.
This is my example conversion of a few existing mmap users. The mtdchar
case is actually disabled right now (and stays disabled), but I did it
because it showed up on my "git grep", and I was familiar with the code
due to fixing an overflow problem in the code in commit 9c603e53d380
("mtdchar: fix offset overflow detection").
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/mtd/mtdchar.c | 32 ++------------------------------
1 file changed, 2 insertions(+), 30 deletions(-)
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1159,45 +1159,17 @@ static int mtdchar_mmap(struct file *fil
struct mtd_file_info *mfi = file->private_data;
struct mtd_info *mtd = mfi->mtd;
struct map_info *map = mtd->priv;
- resource_size_t start, off;
- unsigned long len, vma_len;
/* This is broken because it assumes the MTD device is map-based
and that mtd->priv is a valid struct map_info. It should be
replaced with something that uses the mtd_get_unmapped_area()
operation properly. */
if (0 /*mtd->type == MTD_RAM || mtd->type == MTD_ROM*/) {
- off = get_vm_offset(vma);
- start = map->phys;
- len = PAGE_ALIGN((start & ~PAGE_MASK) + map->size);
- start &= PAGE_MASK;
- vma_len = get_vm_size(vma);
-
- /* Overflow in off+len? */
- if (vma_len + off < off)
- return -EINVAL;
- /* Does it fit in the mapping? */
- if (vma_len + off > len)
- return -EINVAL;
-
- off += start;
- /* Did that overflow? */
- if (off < start)
- return -EINVAL;
- if (set_vm_offset(vma, off) < 0)
- return -EINVAL;
- vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
-
#ifdef pgprot_noncached
- if (file->f_flags & O_DSYNC || off >= __pa(high_memory))
+ if (file->f_flags & O_DSYNC || map->phys >= __pa(high_memory))
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
#endif
- if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
- vma->vm_end - vma->vm_start,
- vma->vm_page_prot))
- return -EAGAIN;
-
- return 0;
+ return vm_iomap_memory(vma, map->phys, map->size);
}
return -ENOSYS;
#else
next prev parent reply other threads:[~2013-04-23 21:52 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-23 21:51 [ 00/42] 3.8.9-stable review Greg Kroah-Hartman
2013-04-23 21:51 ` [ 01/42] powerpc: add a missing label in resume_kernel Greg Kroah-Hartman
2013-04-23 21:52 ` [ 02/42] kvm/powerpc/e500mc: fix tlb invalidation on cpu migration Greg Kroah-Hartman
2013-04-23 21:52 ` [ 03/42] ARM: Do 15e0d9e37c (ARM: pm: let platforms select cpu_suspend support) properly Greg Kroah-Hartman
2013-04-23 21:52 ` [ 04/42] kthread: Prevent unpark race which puts threads on the wrong cpu Greg Kroah-Hartman
2013-04-23 21:52 ` [ 05/42] hrtimer: Dont reinitialize a cpu_base lock on CPU_UP Greg Kroah-Hartman
2013-04-23 21:52 ` [ 06/42] can: mcp251x: add missing IRQF_ONESHOT to request_threaded_irq Greg Kroah-Hartman
2013-04-23 21:52 ` [ 07/42] can: sja1000: fix handling on dt properties on little endian systems Greg Kroah-Hartman
2013-04-23 21:52 ` [ 08/42] hugetlbfs: stop setting VM_DONTDUMP in initializing vma(VM_HUGETLB) Greg Kroah-Hartman
2013-04-23 21:52 ` [ 09/42] hugetlbfs: add swap entry check in follow_hugetlb_page() Greg Kroah-Hartman
2013-04-23 21:52 ` [ 10/42] fs/binfmt_elf.c: fix hugetlb memory check in vma_dump_size() Greg Kroah-Hartman
2013-04-23 21:52 ` [ 11/42] kernel/signal.c: stop info leak via the tkill and the tgkill syscalls Greg Kroah-Hartman
2013-04-23 21:52 ` [ 12/42] hfsplus: fix potential overflow in hfsplus_file_truncate() Greg Kroah-Hartman
2013-04-23 21:52 ` [ 13/42] md: raid1,10: Handle REQ_WRITE_SAME flag in write bios Greg Kroah-Hartman
2013-04-23 21:52 ` [ 14/42] KVM: x86: fix for buffer overflow in handling of MSR_KVM_SYSTEM_TIME (CVE-2013-1796) Greg Kroah-Hartman
2013-04-23 21:52 ` [ 15/42] KVM: x86: Convert MSR_KVM_SYSTEM_TIME to use gfn_to_hva_cache functions (CVE-2013-1797) Greg Kroah-Hartman
2013-04-23 21:52 ` [ 16/42] KVM: Fix bounds checking in ioapic indirect register reads (CVE-2013-1798) Greg Kroah-Hartman
2013-04-23 21:52 ` [ 17/42] KVM: Allow cross page reads and writes from cached translations Greg Kroah-Hartman
2013-04-23 21:52 ` [ 18/42] ARM: i.MX35: enable MAX clock Greg Kroah-Hartman
2013-04-23 21:52 ` [ 19/42] ARM: clk-imx35: Bugfix iomux clock Greg Kroah-Hartman
2013-04-23 21:52 ` [ 20/42] tg3: Add 57766 device support Greg Kroah-Hartman
2013-04-23 21:52 ` [ 21/42] sched: Convert BUG_ON()s in try_to_wake_up_local() to WARN_ON_ONCE()s Greg Kroah-Hartman
2013-04-23 21:52 ` [ 22/42] sched/debug: Fix sd->*_idx limit range avoiding overflow Greg Kroah-Hartman
2013-05-10 2:14 ` Ben Hutchings
2013-05-10 7:59 ` Ingo Molnar
2013-05-28 1:47 ` Ben Hutchings
2013-04-23 21:52 ` [ 23/42] ARM: 7696/1: Fix kexec by setting outer_cache.inv_all for Feroceon Greg Kroah-Hartman
2013-04-23 21:52 ` [ 24/42] ARM: 7698/1: perf: fix group validation when using enable_on_exec Greg Kroah-Hartman
2013-04-23 21:52 ` [ 25/42] ath9k_htc: accept 1.x firmware newer than 1.3 Greg Kroah-Hartman
2013-04-23 21:52 ` [ 26/42] ath9k_hw: change AR9580 initvals to fix a stability issue Greg Kroah-Hartman
2013-04-23 21:52 ` [ 27/42] mac80211: fix cfg80211 interaction on auth/assoc request Greg Kroah-Hartman
2013-04-23 21:52 ` [ 28/42] ssb: implement spurious tone avoidance Greg Kroah-Hartman
2013-04-23 21:52 ` [ 29/42] crypto: algif - suppress sending source address information in recvmsg Greg Kroah-Hartman
2013-04-23 21:52 ` [ 30/42] perf: Treat attr.config as u64 in perf_swevent_init() Greg Kroah-Hartman
2013-04-23 21:52 ` [ 31/42] perf/x86: Fix offcore_rsp valid mask for SNB/IVB Greg Kroah-Hartman
2013-04-23 21:52 ` [ 32/42] userns: Dont let unprivileged users trick privileged users into setting the id_map Greg Kroah-Hartman
2013-04-23 21:52 ` [ 33/42] userns: Check uid_maps openers fsuid, not the current fsuid Greg Kroah-Hartman
2013-04-23 21:52 ` [ 34/42] userns: Changing any namespace id mappings should require privileges Greg Kroah-Hartman
2013-04-23 21:52 ` [ 35/42] vm: add vm_iomap_memory() helper function Greg Kroah-Hartman
2013-04-23 21:52 ` [ 36/42] vm: convert snd_pcm_lib_mmap_iomem() to vm_iomap_memory() helper Greg Kroah-Hartman
2013-04-23 21:52 ` [ 37/42] vm: convert fb_mmap " Greg Kroah-Hartman
2013-04-23 21:52 ` [ 38/42] vm: convert HPET mmap " Greg Kroah-Hartman
2013-04-23 21:52 ` Greg Kroah-Hartman [this message]
2013-04-23 21:52 ` [ 40/42] Btrfs: make sure nbytes are right after log replay Greg Kroah-Hartman
2013-04-23 21:52 ` [ 41/42] s390: move dummy io_remap_pfn_range() to asm/pgtable.h Greg Kroah-Hartman
2013-04-23 21:52 ` [ 42/42] Revert "MIPS: page.h: Provide more readable definition for PAGE_MASK." Greg Kroah-Hartman
2013-04-24 16:23 ` [ 00/42] 3.8.9-stable review Shuah Khan
2013-04-24 16:24 ` Greg Kroah-Hartman
2013-04-25 10:43 ` Satoru Takeuchi
2013-04-25 14:49 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130423215209.434735929@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).