Received: by 10.192.165.156 with SMTP id m28csp549872imm; Wed, 11 Apr 2018 03:37:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx48GtdWwFnwtGiKWZ+SMs54KRRfY1VELqrSdyGYbDuabA18umWhyCorLcqtnjsKZ1tFQ6CIr X-Received: by 2002:a17:902:6590:: with SMTP id c16-v6mr4384865plk.292.1523443043672; Wed, 11 Apr 2018 03:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523443043; cv=none; d=google.com; s=arc-20160816; b=ThmlR2TtyqLCeKBvHE3EZz7URv29i+PVdaxlNc9jGP0K15jbCXdSrmchLjWLtYayPa Cthu1kCbQ/0nWebxSox54Pct5BlHAUBNGTDCB3WETpKIoErSr8ZrUJVxL/f3zkGSSLUw sdM8S231uj9DBCu8RivNpH6yy6YtYPlvn5Nb3+JdNrV0gXuGYFz5/FgonbUyLp60/XGK ppG4rbGz4p1nErMY39VAIEQeGqQcsvdRNJfdYYJQo8OP3qi7x7vyCY9xUdH3VuVobRVE eLKe8OZtazlIYWBQr4G8XGuSrxAQJprWQs0Nsu71TDPSP5KQmP3h4uu+/+Ray0pUFWnv ss4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=4VSm+YqaA2eXwicGtekvtpE78ohURh3iWO0YX8r2xR8=; b=kKb1an7TIcPKpGNeIJjHUdzQoN/vxlY+JTNifbTIJNHZlqYMbdo+haV/jCL7aJN60a oPTM/R4AfBDJz/+uz1jBU0wlD7K8kuCiPKw9fBowYoe6wNb5NECQg3qkXrCp69TVXONo pu4VPQ7LGeqiB0FBVWgMk03fjelYMwBYQSV0MK4mwjCCP2MusKSmBKWK3EyPRHutY7k/ VBz5M0mNDy7h0ceVYBB/HcJfEBWw664jB6XMriAbwIzq1G74k8TPOAAp0PVugq1faVV9 pzN8p0xn8cYjGVFvMoP6zr7ZhSAhI9RKIZa3UMhMXnngwUGvveVClKqxHe8/BT4pUqa0 DQJQ== 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 h132si667268pfe.52.2018.04.11.03.36.46; Wed, 11 Apr 2018 03:37:23 -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 S1752297AbeDKKau (ORCPT + 99 others); Wed, 11 Apr 2018 06:30:50 -0400 Received: from mail.windriver.com ([147.11.1.11]:54109 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751409AbeDKKat (ORCPT ); Wed, 11 Apr 2018 06:30:49 -0400 X-Greylist: delayed 916 seconds by postgrey-1.27 at vger.kernel.org; Wed, 11 Apr 2018 06:30:49 EDT Received: from ALA-HCA.corp.ad.wrs.com ([147.11.189.40]) by mail.windriver.com (8.15.2/8.15.1) with ESMTPS id w3BAUOlu024826 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Wed, 11 Apr 2018 03:30:24 -0700 (PDT) Received: from [128.224.155.98] (128.224.155.98) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 11 Apr 2018 03:30:23 -0700 Subject: Re: [PATCH v3] net: tipc: Replace GFP_ATOMIC with GFP_KERNEL in tipc_mon_create To: Jia-Ju Bai , , CC: , , References: <1523442262-4823-1-git-send-email-baijiaju1990@gmail.com> From: Ying Xue Message-ID: <7bf48d79-54fe-421a-e04c-f2d6cd2c71e2@windriver.com> Date: Wed, 11 Apr 2018 18:26:42 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1523442262-4823-1-git-send-email-baijiaju1990@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [128.224.155.98] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/11/2018 06:24 PM, Jia-Ju Bai wrote: > tipc_mon_create() is never called in atomic context. > > The call chain ending up at tipc_mon_create() is: > [1] tipc_mon_create() <- tipc_enable_bearer() <- tipc_nl_bearer_enable() > tipc_nl_bearer_enable() calls rtnl_lock(), which indicates this function > is not called in atomic context. > > Despite never getting called from atomic context, > tipc_mon_create() calls kzalloc() with GFP_ATOMIC, > which does not sleep for allocation. > GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL, > which can sleep and improve the possibility of successful allocation. > > This is found by a static analysis tool named DCNS written by myself. > And I also manually check it. > > Signed-off-by: Jia-Ju Bai Acked-by: Ying Xue > --- > v2: > * Modify the description of GFP_ATOMIC in v1. > Thank Eric for good advice. > v3: > * Modify wrong text in description in v2. > Thank Ying for good advice. > --- > net/tipc/monitor.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c > index 9e109bb..9714d80 100644 > --- a/net/tipc/monitor.c > +++ b/net/tipc/monitor.c > @@ -604,9 +604,9 @@ int tipc_mon_create(struct net *net, int bearer_id) > if (tn->monitors[bearer_id]) > return 0; > > - mon = kzalloc(sizeof(*mon), GFP_ATOMIC); > - self = kzalloc(sizeof(*self), GFP_ATOMIC); > - dom = kzalloc(sizeof(*dom), GFP_ATOMIC); > + mon = kzalloc(sizeof(*mon), GFP_KERNEL); > + self = kzalloc(sizeof(*self), GFP_KERNEL); > + dom = kzalloc(sizeof(*dom), GFP_KERNEL); > if (!mon || !self || !dom) { > kfree(mon); > kfree(self); >