From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chen Gang Date: Fri, 04 Sep 2015 03:43:15 +0000 Subject: Re: [PATCH] arch: ia64: kernel: perfmon: Check return value of insert_vm_struct() Message-Id: <55E91353.8010005@21cn.com> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: kernel mailing list , "linux-ia64@vger.kernel.org" Cc: Andrew Morton , tony.luck@intel.com, Fenghua Yu Hello Maintainers: Please help check this patch when you have time. Thanks. On 8/24/15 01:18, Chen Gang wrote: > 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)); > -- > > > -- Chen Gang (陈刚) Open, share, and attitude like air, water, and life which God blessed From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756972AbbIDDl3 (ORCPT ); Thu, 3 Sep 2015 23:41:29 -0400 Received: from smtpfree.forptr.21cn.com ([183.56.131.105]:11461 "EHLO 21cn.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1756746AbbIDDl2 (ORCPT ); Thu, 3 Sep 2015 23:41:28 -0400 HMM_SOURCE_IP: 10.64.8.32:12465.824349107 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP 0/X-Total-Score: 0: 1/X-Total-Score: 0: X-FILTER-SCORE: to=<87868f888996824f9a96618a8f95868d4f84908e>, score=<1441338079wRgrW/uBpYwwwwwRwwgwwrV5ncSUftA6VVVVV5VVnVVc> X-REAL-FROM: gchen_5i5j@21cn.com X-Receive-IP: 124.166.242.181 Message-ID: <55E91353.8010005@21cn.com> Date: Fri, 04 Sep 2015 11:43:15 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: kernel mailing list , "linux-ia64@vger.kernel.org" CC: Andrew Morton , tony.luck@intel.com, Fenghua Yu Subject: Re: [PATCH] arch: ia64: kernel: perfmon: Check return value of insert_vm_struct() References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Maintainers: Please help check this patch when you have time. Thanks. On 8/24/15 01:18, Chen Gang wrote: > 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)); > -- > > > -- Chen Gang (陈刚) Open, share, and attitude like air, water, and life which God blessed