Received: by 10.213.65.68 with SMTP id h4csp3289549imn; Mon, 9 Apr 2018 18:20:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx48/NzXnsY4bQJq+fXt5vA63zDOszVwvDGF6SRj3Ytog29JprVNtYC6vjxJ9ETKZTwFbXycz X-Received: by 2002:a17:902:a506:: with SMTP id s6-v6mr5820736plq.191.1523323249894; Mon, 09 Apr 2018 18:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523323249; cv=none; d=google.com; s=arc-20160816; b=teNjAe3Zin+s8rA8dG6F/zTNTvyFnL19qO23KKuqXUhqC9n5mw+gdtkKq4qxZgDjuI bnef56IZXh5xSvxusuk3sdBMpdq7hflLdTEzRanipPG0qDPLvwE0JInm2nL0tzV0PGqA oIBV5tDLNiyxJ3/Cbf8C3GAXa6RT9OKJYWB/YTaxmlsGD4GnHJz034lxDQtSLX9rOwPP gXHPuIQF2BlWmx0i0MZzwtiQot+oocoRj13aLC2PiZkJIAN0sx4clSpn9Uq7uDuC57bG p87K3a31ulrTLHmkZdUnW3wPR0mhwDIcq7jO1nsG3lyK5kNfv+HJLVdbBLhs18K/Libh 3wtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=OqcfSvYkqzia0gSdsDFCS3g5ij1tTTRQPDbBXslxc+o=; b=ncw8dMa38YxhInBOcpAPB93ZW95/i/uqDAz2STAklrT8vd6wknOpRVwwfNsTVRE29v po+JcoAKPYTFc/ilhGOBqq5/ay39NQbrRhjNNO76l5qc9cA0Iu1oB9v6i9MNhZucf2xf VFDcUpcL1XujKkEsVdV6o9YehQ5fiH5x2QZRxg0KmUXCgn528FBJlCh2+RAtUO78IC+Y bO9jYkqO+V4XwTu8fMv2zCBHxKPGreOzk3FEyycqHZNUmNJ3skKF0XnM/ETcaQONsHxm kNy6JKIQfEDrCh50NSuVLyuqLDRiSg7acAys9Rp5HEKfAV4EMUMzVNLPhApBg7dIO509 f7Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=apI3ou4I; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l2si139993pgq.460.2018.04.09.18.20.12; Mon, 09 Apr 2018 18:20:49 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=apI3ou4I; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752215AbeDJBQQ (ORCPT + 99 others); Mon, 9 Apr 2018 21:16:16 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:43243 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751367AbeDJBQO (ORCPT ); Mon, 9 Apr 2018 21:16:14 -0400 Received: by mail-pf0-f194.google.com with SMTP id j2so6846515pff.10; Mon, 09 Apr 2018 18:16:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=OqcfSvYkqzia0gSdsDFCS3g5ij1tTTRQPDbBXslxc+o=; b=apI3ou4IgxXeMABFHGrgM4NfJUKfExwnDVr/JyeO3U6Zo9rhycsq7Ue/ydxIWtzzdx Jmrwv+rEMthmncLWLRxE7DixdQGCCifJWIDpnPwzZDgzv2W7gNcMeyXxT5x52nLk76uo kvs5SNZVjb9gw8tE3HetCkVvS1ySUBwuxhuF9eeAa/ArfAz3oMFwmcbbXNpoUOoav0I2 9aSNzn7GugzR/19+MrklSkRrae7HpkrmKk9KPAJ7pTcTNVOmT8Ssnyq6weybMX+FZoWq zrp455p9xHdALHa5UBpWqPzjdTPXe92EuR7l9er/FF9P5/F2lnfssNz182BEb4ucxOkm RUTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=OqcfSvYkqzia0gSdsDFCS3g5ij1tTTRQPDbBXslxc+o=; b=bh/fGfxMuWxeYhqgRtUN9qexkLlcd4EBY8EA/xDXmcz/Ub4Bee1uYm1R/hAfrTScHY ygiLvgywVJvPDD8ztc3wfkPUDxoLmSiI1AejBYTm/ZyGAJrOho2M3jTBuy2vVwevZY0a D+kTX30TuJpuYQ0uo7NcYrSgxyuahCAvJ/yNeYTQCDx586Ufu5jo7R6LOZUN0sW01wVE JLNx8PMcGJf3e/94VpFffpPCVA8zIY1uAmOaiwzvgalV5IvjP04PONixDWOXHSxwlVVQ tSLkRcEm+hy2n32w7L0FmQ3xkOh5HBJxLOR0kFT/Ve+GaU9iehNsJhW9ioei8nY0VhlK Rv2Q== X-Gm-Message-State: AElRT7EWHzCoa/42jedlITMU+9w+oeyZN5BJTEpBLWoxUiwi0gdCz4Bx GmIVfvoA5Wz+E6hHm74sW8o= X-Received: by 10.99.100.68 with SMTP id y65mr27062933pgb.257.1523322973972; Mon, 09 Apr 2018 18:16:13 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:39e9:70fb:21a6:f4d2]) by smtp.gmail.com with ESMTPSA id o2sm2189925pgq.87.2018.04.09.18.16.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Apr 2018 18:16:13 -0700 (PDT) From: Jia-Ju Bai To: gerrit@erg.abdn.ac.uk, davem@davemloft.net Cc: dccp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH v2] net: tipc: Replace GFP_ATOMIC with GFP_KERNEL in tipc_mon_create Date: Tue, 10 Apr 2018 09:16:08 +0800 Message-Id: <1523322968-27947-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org tipc_mon_create() is never called in atomic context. The call chain ending up at dn_route_init() 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 sucessful 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 --- v2: * Modify the description of GFP_ATOMIC in v1. Thank Eric 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); -- 1.9.1