diff options
author | Arnd Bergmann <arnd@arndb.de> | 2012-07-17 20:41:50 (GMT) |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2012-07-17 20:41:50 (GMT) |
commit | 36c678f3c91ac92e9524abcf9b39f9f539d60279 (patch) | |
tree | c9c0df006a7e9bcc14492b1d1fa6aa2c5c43d3a3 /mm/madvise.c | |
parent | 4450cb7d586c3d8f6615ee437eab1d1e064b20c0 (diff) | |
parent | 14ac5b884eff23f53139dd4508f428aee906d8c2 (diff) | |
download | linux-36c678f3c91ac92e9524abcf9b39f9f539d60279.tar.xz |
Merge tag 'imx-clk' of git://git.pengutronix.de/git/imx/linux-2.6 into next/clk
From Sascha Hauer <s.hauer@pengutronix.de>:
i.MX clk noncritical fixes and updates
* tag 'imx-clk' of git://git.pengutronix.de/git/imx/linux-2.6:
ARM: imx: clk-imx31: Fix clock id for rnga driver
ARM: imx: add missing item to the list of clock event modes
ARM: i.MX5x CSPI: Fixed clock name for CSPI
ARM: i.MX5x clocks: Fix GPT clocks
ARM: i.MX5x clocks: Fix parent for PWM clocks
ARM: i.MX5x clocks: Add EPIT support
ARM: mx27: Reenable silicon version print
ARM: clk-imx27: Fix rtc clock id
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'mm/madvise.c')
-rw-r--r-- | mm/madvise.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/mm/madvise.c b/mm/madvise.c index deff1b6..14d260f 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -15,6 +15,7 @@ #include <linux/sched.h> #include <linux/ksm.h> #include <linux/fs.h> +#include <linux/file.h> /* * Any behaviour which results in changes to the vma->vm_flags needs to @@ -204,14 +205,16 @@ static long madvise_remove(struct vm_area_struct *vma, { loff_t offset; int error; + struct file *f; *prev = NULL; /* tell sys_madvise we drop mmap_sem */ if (vma->vm_flags & (VM_LOCKED|VM_NONLINEAR|VM_HUGETLB)) return -EINVAL; - if (!vma->vm_file || !vma->vm_file->f_mapping - || !vma->vm_file->f_mapping->host) { + f = vma->vm_file; + + if (!f || !f->f_mapping || !f->f_mapping->host) { return -EINVAL; } @@ -221,11 +224,18 @@ static long madvise_remove(struct vm_area_struct *vma, offset = (loff_t)(start - vma->vm_start) + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); - /* filesystem's fallocate may need to take i_mutex */ + /* + * Filesystem's fallocate may need to take i_mutex. We need to + * explicitly grab a reference because the vma (and hence the + * vma's reference to the file) can go away as soon as we drop + * mmap_sem. + */ + get_file(f); up_read(¤t->mm->mmap_sem); - error = do_fallocate(vma->vm_file, + error = do_fallocate(f, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, end - start); + fput(f); down_read(¤t->mm->mmap_sem); return error; } |