[PATCH] ia64: perfmon: fix a possible file refcnt leak

From: Eric Dumazet
Date: Tue Apr 08 2014 - 11:57:23 EST


From: Eric Dumazet <edumazet@xxxxxxxxxx>

get_file() is called before error checks in pfm_smpl_buffer_alloc()

Signed-off-by: Eric Dumazet <edumazet@xxxxxxxxxx>
Fixes: cb0942b81249 ("make get_file() return its argument")
---
arch/ia64/kernel/perfmon.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index d841c4bd6864..a7221393612e 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2297,7 +2297,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
* partially initialize the vma for the sampling buffer
*/
vma->vm_mm = mm;
- vma->vm_file = get_file(filp);
+ vma->vm_file = filp;
vma->vm_flags = VM_READ|VM_MAYREAD|VM_DONTEXPAND|VM_DONTDUMP;
vma->vm_page_prot = PAGE_READONLY; /* XXX may need to change */

@@ -2342,7 +2342,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
*/
insert_vm_struct(mm, vma);

- vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
+ vm_stat_account(vma->vm_mm, vma->vm_flags, get_file(filp),
vma_pages(vma));
up_write(&task->mm->mmap_sem);



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/