public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arch: ia64: kernel: perfmon: Check return value of insert_vm_struct()
@ 2015-08-23 17:18 Chen Gang
  2015-09-04  3:43 ` Chen Gang
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Gang @ 2015-08-23 17:18 UTC (permalink / raw)
  To: kernel mailing list, linux-ia64@vger.kernel.org

In pfm_smpl_buffer_alloc, insert_vm_struct may also return -ENOMEM, so
need check it too.

And insert_vm_struct needn't consider about pfm_remap_buffer in failure
process ("goto error" is enough):

 - pfm_remap_buffer doen't consider about remap_pfn_range.

 - It is about the relationship between vma and smpl_buf.

 - SO if both vma and smpl_buf are released ("goto error"), all things
   are OK.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 arch/ia64/kernel/perfmon.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 60e02f7..ae77946 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2330,7 +2330,11 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
 	 * now insert the vma in the vm list for the process, must be
 	 * done with mmap lock held
 	 */
-	insert_vm_struct(mm, vma);
+	if (insert_vm_struct(mm, vma)) {
+		DPRINT(("Can't insert vm structure.\n"));
+		up_write(&task->mm->mmap_sem);
+		goto error;
+	}
 
 	vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
 							vma_pages(vma));
-- 

 		 	   		  

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-04  3:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-23 17:18 [PATCH] arch: ia64: kernel: perfmon: Check return value of insert_vm_struct() Chen Gang
2015-09-04  3:43 ` Chen Gang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox