Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5263663imm; Tue, 12 Jun 2018 05:21:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK5UPifxIQsNYwqqIZ0FneR5TAsvx8CgzqvhOWSa66yiwWTGR+fxZMt7dgUC+te/ICcOtY9 X-Received: by 2002:a62:be0a:: with SMTP id l10-v6mr165841pff.180.1528806098034; Tue, 12 Jun 2018 05:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528806098; cv=none; d=google.com; s=arc-20160816; b=jv2auu3vbLT0dI1bOKrqMJ7Z0b45vUxQqeDBeAEFJykCQfXG8IRNLo0MB4ebweVVXS EmsWXl35ak6sAZqi8sHqboGdB4T5pXbnTA7QGJXw/np23gyNhlyAuMzm0x/z9HUi5qgJ 7UNQCguXe8pmLaNgJvqsAj+sxt3ro2ASsUdrkha/OkUh67KAxhSLh8+/PNau1gFaYbn1 k77r2XWBkwJ0IHsd2bcgCpsnpVaAXwsw1oK8FBQHI/IBgnaH8r6Z5nacS6xcM3eqNHL4 NgkxvZj7EDm2P6eSux4CIpT75iEe5ceDDGyxC5L1qwdRXG7XARLOp57vjHQ1uNpgKNmp 1ZTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=ufvDXISdzCWdY6wlO3Id4eu5TV+7TnKWXhsCTN3Qwp0=; b=lDVzrFVTt2YTT9I99+N4Zlyl+SzDeIUfhEhVRkkakHOuzpjU5qnG1al76SWxfN6ncH uI2SUP6mR/wnZM5avqYvkrnnr55spL/nmKM2cdnyisrKdiQiApbRX2cq+ciyDkB/FChC 4m1GcnEYwMQiXPQ2c9naXK/Oa/WgLOeo6ixH99ynI0NdUev7t9J+cthUkrh/OlyIZ107 LnZ2U9NNP+n6pG4kNvTqgTW+cSNtR0OjFwvasxXLMm3lM4CkU3vnP2yVI2pnobr5W14c li8pMJzBYU2kraTGOjIZjM7Suvqfn4DcpVJPvi9WqsAHFO8pIoa5i4StawmeWAkb0K1T Sqaw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j84-v6si18118pfj.79.2018.06.12.05.21.23; Tue, 12 Jun 2018 05:21:38 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933417AbeFLMSu convert rfc822-to-8bit (ORCPT + 99 others); Tue, 12 Jun 2018 08:18:50 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38380 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932412AbeFLMSt (ORCPT ); Tue, 12 Jun 2018 08:18:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2C4B54021CC2; Tue, 12 Jun 2018 12:18:49 +0000 (UTC) Received: from 117.195.187.81.in-addr.arpa (unknown [10.33.36.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1FEC178BC; Tue, 12 Jun 2018 12:18:45 +0000 (UTC) Subject: Re: [Cluster-devel] [PATCH] gfs2: add error handling for kmem_cache_zalloc To: "cgxu519@gmx.com" , Zhouyang Jia Cc: cluster-devel@redhat.com, linux-kernel@vger.kernel.org References: <1528774692-38990-1-git-send-email-jiazhouyang09@gmail.com> From: Steven Whitehouse Message-ID: Date: Tue, 12 Jun 2018 13:18:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8BIT Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 12 Jun 2018 12:18:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 12 Jun 2018 12:18:49 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'swhiteho@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 12/06/18 08:24, cgxu519@gmx.com wrote: >> ?? 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. Indeed. It is one of the few GFP_NOFAIL allocations left in GFS2. It would be good to figure out how to remove the last few of these allocations, but simply adding a check for a NULL return is not the right solution here anyway. I would also add that if this problem was easier then I'm sure we'd have solved it before - the right answer is not very obvious in this case, Steve. > >> 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 >> >