Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753096AbbHWRTA (ORCPT ); Sun, 23 Aug 2015 13:19:00 -0400 Received: from col004-omc1s4.hotmail.com ([65.55.34.14]:59375 "EHLO COL004-OMC1S4.hotmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752101AbbHWRS7 convert rfc822-to-8bit (ORCPT ); Sun, 23 Aug 2015 13:18:59 -0400 X-TMN: [VgDxgGYOsCwEuZYZJe7ygmcXRDhj2N0T] X-Originating-Email: [xili_gchen_5257@hotmail.com] Message-ID: From: Chen Gang To: kernel mailing list , "linux-ia64@vger.kernel.org" Subject: [PATCH] arch: ia64: kernel: perfmon: Check return value of insert_vm_struct() Date: Mon, 24 Aug 2015 01:18:58 +0800 Importance: Normal Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginalArrivalTime: 23 Aug 2015 17:18:59.0144 (UTC) FILETIME=[CC697C80:01D0DDC7] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1423 Lines: 42 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 --- ?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)); --? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/