Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4997027imm; Tue, 12 Jun 2018 00:25:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIeQ9OtEfOqiMA9UvhuWy7d7i30gKvGwWre5cowmUFoWGNr28EXelPNcwuk61RbiGrCfu5J X-Received: by 2002:a62:9d58:: with SMTP id i85-v6mr2635563pfd.76.1528788332339; Tue, 12 Jun 2018 00:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528788332; cv=none; d=google.com; s=arc-20160816; b=RuP4S9dBmkXAt5BcyzTbN5AVFHa2a/APOMwDDBHJYNrTiHlzfK3Q4LxfwuvlTQHR+t vKw+q8g83lTIptn1nmY7TqNltMlUqn4RWRyBWbNeIV1HvvEM5JNfBBAYMsMxPLqjz2wz kTGJjzxx4xh5TUCJfHFyQV47vgdcSG9L+2aZk9XgVUB5mVAAvy0u5TYgv2k4jUKnSfd0 /1MyiIL1MjMVoRTdxiDSWgwYoTE5zsnVdfKDmVaJJt+NKqGGJCkYxALzUs5yauIzWks9 CNS9DBh4YxW4pS7hS1Rn7gxz5Ilzc9MXxQUffy1B48ewlnxjQr9mmLsGt/MAIgHapNtr Dxsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:arc-authentication-results; bh=0QmE8ZJdbJH7vVCZwyweetPABpljW0Eb5haykhg2uYY=; b=NlXe+EKgIodk8y5GJqt63ERoxhQO+aBv5TFeExDytACkxzRQFoMiJDNxGXrAE2UJFV Fv4x6Gl/ErcPDlNI9Y4qXKV2On/Jikzze8NE2AlfCRaJNWCFii7x6ec/zjZVPWJOOOJp HPMeH/X+oJg/r2O43xdZna54V+YTLjCpxOHqs9wxCH8wOiiHc0QxlO9oulP0W54k1FeA IllKyvyVEtwvFXqHscmmPMXHeMZvopnvZtTtWubsVV+X6WGvaay0WZgJBWlISQVcEup+ /YLGh7OcnNMamIBeOQMLEs07zXw3XygmPRABCeLnDz7mNuqkyAed1dcA5Uxk20CneYdO hgvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4-v6si247252plp.357.2018.06.12.00.25.17; Tue, 12 Jun 2018 00:25:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933249AbeFLHYy convert rfc822-to-8bit (ORCPT + 99 others); Tue, 12 Jun 2018 03:24:54 -0400 Received: from mout.gmx.net ([212.227.17.21]:50977 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932944AbeFLHYx (ORCPT ); Tue, 12 Jun 2018 03:24:53 -0400 Received: from [172.17.45.7] ([122.224.77.194]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MMkgl-1fK6Ph1gMh-008eZV; Tue, 12 Jun 2018 09:24:47 +0200 Content-Type: text/plain; charset=gb2312 Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Re: [PATCH] gfs2: add error handling for kmem_cache_zalloc From: "cgxu519@gmx.com" In-Reply-To: <1528774692-38990-1-git-send-email-jiazhouyang09@gmail.com> Date: Tue, 12 Jun 2018 15:24:41 +0800 Cc: "cgxu519@gmx.com" , Bob Peterson , Andreas Gruenbacher , cluster-devel@redhat.com, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <1528774692-38990-1-git-send-email-jiazhouyang09@gmail.com> To: Zhouyang Jia X-Mailer: Apple Mail (2.3445.6.18) X-Provags-ID: V03:K1:PG5soE5SB63s6dvjyhZYRGuHzJc8EN8XMyZbq2LnGQto4AQrtTi 1FITaMiqYvUN9LpZs1CsR3OCm7+IroPTfYs69xDNmnP90CewXo4VUyb9ABawR6Eu2gQLeXb 1ET059+Tr3v7pCCPNrs/TVYUq00AypCfl1BYZQIvJNlPnGzRuvnR58evN91+agGyYix8vJP YdTmijtWZXLqPoY9ik8CA== X-UI-Out-Filterresults: notjunk:1;V01:K0:YiMrRCEEeig=:iRB4D+x62cfQ1Z9U6tJ2XV eLUfHbESEUJDKAhSmGVjMu60V5Fuypk9Ulo6ClmpD3bPyBG8NLXXRWf268sRcDFEmNVoy+gcI 0Ha9SIpDSG7OJPKFkqudBH5gZaRiIaq07hG2HxXAaquT0O0V5ScLyNnRvvUNWQNJLxM34D7oL bO0wPf+EEyBAztOnFuJhOEzYqk2aTzojgDafVDv5XhZoiLU4IYwSlWC2rjJ+xgqiOe63fwqSO 2QrUzJu3kMt+/2R9uqIiT9gb9pvj65rTfTfr/ppafZumIsyxIdQwOFCcdzuC0cyZaybqvlQ4/ dfUd5dpj6B+wvS0A9W+xLhTb14JJBZl23JTM0Ak76/yb5HOQNG09WWi6zFSo3DsqQ6kbGim6W 2ySCOi9QVeV84SLRcZJzUAxQwvFAgSnq/p6lz/A50DT5YsieiDmQ1B/+VSGDI3Jl68FJT9Ltk 3fxdnnldhbJlFg0omcBE/ImNpT4KD67QohJQQUFoCzLfE0c76a+hrdBuXcaxUCDwLRV9VcVFQ +rUmO7qXRQzPwfFPWsTwL3Na9BI2BHt7BEzDH1vcDh7u0CzLbGmhz3eWqXYo/GZ73ERok+Xkw qMHUUXCtN3M1oDhQyizEm3g2uxkBWApGy/DVbeV/SnLzzegaOVjoTQ+Xu926yfkAyYGwPYPim 3eUBKR1LSP4wcVFIzhVzS1lT47J/4qgNboiVT3lJkC6nVsXWkf6Tk1h53oz/cuSPDX8LYA5ql 9E6pijx+KWNq6Ocvh+9fboDafOfMHY9qUZHV8q2c7laIzMktHC8hvTnML525n4OLM8a4p2jVm vunxREP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > ?? 2018??6??12?գ?????11:38??Zhouyang Jia д???? > > When kmem_cache_zalloc fails, the lack of error-handling code may > cause unexpected results. > > This patch adds error-handling code after calling kmem_cache_zalloc. Should not fail on this case. Thanks, Chengguang. > > Signed-off-by: Zhouyang Jia > --- > fs/gfs2/trans.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c > index 064c9a0..da81eb4 100644 > --- a/fs/gfs2/trans.c > +++ b/fs/gfs2/trans.c > @@ -130,6 +130,9 @@ static struct gfs2_bufdata *gfs2_alloc_bufdata(struct gfs2_glock *gl, > struct gfs2_bufdata *bd; > > bd = kmem_cache_zalloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL); > + if (!bd) > + return NULL; > + > bd->bd_bh = bh; > bd->bd_gl = gl; > bd->bd_ops = lops; > -- > 2.7.4 >