From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754566AbbHXNe1 (ORCPT ); Mon, 24 Aug 2015 09:34:27 -0400 Received: from col004-omc2s2.hotmail.com ([65.55.34.76]:60708 "EHLO COL004-OMC2S2.hotmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751966AbbHXNe0 (ORCPT ); Mon, 24 Aug 2015 09:34:26 -0400 X-TMN: [MkPpU3jRMD+Oov3LDYxCTSuUrxgbLViG] X-Originating-Email: [xili_gchen_5257@hotmail.com] Message-ID: From: Chen Gang To: Michal Hocko CC: Andrew Morton , "kirill.shutemov@linux.intel.com" , "riel@redhat.com" , "sasha.levin@oracle.com" , "gang.chen.5i5j@gmail.com" , Linux Memory , kernel mailing list Subject: Re: [PATCH] mm: mmap: Check all failures before set values Date: Mon, 24 Aug 2015 21:34:25 +0800 Importance: Normal In-Reply-To: <55DB1D94.3050404@hotmail.com> References: <1440349179-18304-1-git-send-email-gang.chen.5i5j@qq.com> <20150824113212.GL17078@dhcp22.suse.cz>,<55DB1D94.3050404@hotmail.com> Content-Type: text/plain; charset="gb2312" MIME-Version: 1.0 X-OriginalArrivalTime: 24 Aug 2015 13:34:25.0477 (UTC) FILETIME=[97E4CF50:01D0DE71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id t7ODYWng011336 On 8/24/15 19:32, Michal Hocko wrote: > On Mon 24-08-15 00:59:39, gang.chen.5i5j@qq.com wrote: >>> From: Chen Gang >>> >>> When failure occurs and return, vma->vm_pgoff is already set, which is >>> not a good idea. > Why? The vma is not inserted anywhere and the failure path is supposed > to simply free the vma. > It can save several insns when failure occurs. It is always a little better to let the external function suppose fewer callers' behalf. It can save the code readers' (especially new readers') time resource to avoid to analyze why set 'vma->vm_pgoff' before checking '-ENOMEM' (may it cause issue? or is 'vm_pgoff' related with the next checking?). Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¥Š{±þG«�éÿŠ{ayºʇڙë,j­¢f£¢·hš�ï�êÿ‘êçz_è®(­éšŽŠÝ¢j"�ú¶m§ÿÿ¾«þG«�éÿ¢¸?™¨è­Ú&£ø§~�á¶iO•æ¬z·švØ^¶m§ÿÿà ÿ¶ìÿ¢¸?–I¥