Received: by 10.213.65.68 with SMTP id h4csp3830045imn; Tue, 10 Apr 2018 05:27:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/K2hije+AGxsDqoEiH+2clp58yjzE3Z+LAY1o//WS+aZQ/nsmiEmrVlWyNn4k0Znj24pi0 X-Received: by 10.101.81.204 with SMTP id i12mr161484pgq.206.1523363266001; Tue, 10 Apr 2018 05:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523363265; cv=none; d=google.com; s=arc-20160816; b=SAcbA0ixVe7jCzaS5A60H+Yv3TAJK5VWbbz9LSONUt76BRVEPsxzoXE9GDEt8mEwSC CZpUvT4/UmnPTlkRA+0C3Dw7Gm76ZwwQFwfUmqWnujobK7KFyxLS3j9942+jnZLIfCAI CloaqXh+iYoS/FmBxfGVYgrszecv0/ddS4vYThktWF46jOQebvLmRQ4RXEfD0n/L3gsG uc7mMpFYP8XYlCRkp33oyP0LCt92zDGAAWbYE2rCZNwmI1fQQkYVA95M5Zm6o+c3Ly2d f/n1dq3nGtjr8KMIoK0iS216X5pQnVG4A9ZOfwQs3HlYQ1g8ikBR3aiBmj+YmwFH7yY0 jv1g== 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=kMFjGcy+k0BqNk2Ux9NK5mHC0bHcHQqi/cNMOnpJPo8=; b=j9r9OSiIlQaUjFVzEhv+C1FKOfnw8bljUAQ8FkhO057HidCJQwnTcVsfrbszVwKNAw r9e6Kdy6LtI13U6LoXGfuR2NCrkMAYl7ZlHjeZqy3kt0+5BXdwuAiqAYjal3N4rxB8Ej wnbLHDEDlRCTG4drfhKKmkHBrxq5In7U4S9DN4uVZYkN559WBypei52v0iC1sGEloPmG Xg9iam6QgDQnJms2fx7wjSVLPieHu/AOnFzkACjB01GHfRmLV5ecJSIUfDMqvVbxEgfQ vosAH/VgKekkfw/B9Z/00Xtdv3D3w5mT10w2lQ9N/gKqlzpxyrRPPuq+xnHMWi2QdGDb qLYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YBuL0/JH; 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 9-v6si2607956plf.283.2018.04.10.05.27.09; Tue, 10 Apr 2018 05:27:45 -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=YBuL0/JH; 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 S1752810AbeDJMXj (ORCPT + 99 others); Tue, 10 Apr 2018 08:23:39 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:35987 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752428AbeDJMXi (ORCPT ); Tue, 10 Apr 2018 08:23:38 -0400 Received: by mail-pl0-f68.google.com with SMTP id 91-v6so7414639pld.3 for ; Tue, 10 Apr 2018 05:23:38 -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=kMFjGcy+k0BqNk2Ux9NK5mHC0bHcHQqi/cNMOnpJPo8=; b=YBuL0/JHvlYqS0/Rn1qHidnVkh80eX5iSSNnBrfAylONRu3e0iq7iCPGKZslqttECs Wd7KNERAd0nK1CrLbl33D/FWf8aFmLVessLZ9sQTLuzvLJguV2NVt/37zspUacY+7KtQ f9O6ynyaKUDKc3XAT6+HFLVPj3qwhQoiwKGPmIxFk0PUsKsU6/Ab/o28ezKi+lXvbQxR G2V+6XX4Kt2sNSFOAK3717VwbUArCRXdFQehmQLyTzBcz7Sc1/OjOeMYRa6XF013vD4g qWFRX0NCjfEM5UFtCbhEdzE57m6joSHlVFPe0axqkDCWeB+wW1dRzS3kmhaiN3Grr49O DnhQ== 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=kMFjGcy+k0BqNk2Ux9NK5mHC0bHcHQqi/cNMOnpJPo8=; b=d6312a6iDZe07UWrpXapVcBeDFiQa5A8ld1Hicr3SGnGYKQVPgq87HkFFrhaQVC1lb IpkpQrJpfcKkodZOxKyWNYeW8E66nMyKVoIi91s7E5UpYYygTWZ/FrTnTnBwqCZOAqmh dccqrZ8jqYQmS1pzszymenDHs9k3bnK+toxO1yMxngkQu+w/MkH/BxKonx0thVC6yyWi OD8evWx6lPoz0Byx1HFFvmW6DlTzqp5ND2HNiOHw7tBoO2sfl6XAOUVctTGvkcDAbUg0 Rni1DLehi1DikY/wShNZHhOUZnAmCN61NdBsvmlTliMdNSkM5sSH1/VcZ0sjqdobGRAr CqHg== X-Gm-Message-State: ALQs6tCZpW6l985+bN0JrKbHGbN2SAqSqPowVejPl0eU81NxVN/hbRBx jTwEqs0nxDIjHyFlXacK/pz+B8jA X-Received: by 2002:a17:902:8a94:: with SMTP id p20-v6mr230352plo.94.1523363018290; Tue, 10 Apr 2018 05:23:38 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:8dc7:7954:4991:f324]) by smtp.gmail.com with ESMTPSA id r11sm6473963pfg.0.2018.04.10.05.23.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 05:23:37 -0700 (PDT) From: Jia-Ju Bai To: gregkh@linuxfoundation.org, suniel.spartan@gmail.com Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 2/6] staging: rtl8192u: Replace GFP_ATOMIC with GFP_KERNEL in ieee80211_tkip_init Date: Tue, 10 Apr 2018 20:23:29 +0800 Message-Id: <1523363009-30846-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 ieee80211_tkip_init() is never called in atomic context. ieee80211_tkip_init() is only set as ".init" in struct ieee80211_crypto_ops. The call chains ending up at "->init" function are: [1] ->init() <- ieee80211_wpa_set_encryption() <- ieee80211_wpa_supplicant_ioctl() [2] ->init() <- ieee80211_wx_set_encode_ext_rsl() <- r8192_wx_set_enc_ext() [3] ->init() <- ieee80211_wx_set_encode_rsl() <- r8192_wx_set_enc() ieee80211_wpa_supplicant_ioctl(), r8192_wx_set_enc_ext() and r8192_wx_set_enc() call mutex_lock(), which indicates these functions are not called in atomic context. Despite never getting called from atomic context, ieee80211_tkip_init() 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 --- drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c index 60ecfec..a7efaae 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c @@ -66,7 +66,7 @@ static void *ieee80211_tkip_init(int key_idx) { struct ieee80211_tkip_data *priv; - priv = kzalloc(sizeof(*priv), GFP_ATOMIC); + priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) goto fail; priv->key_idx = key_idx; -- 1.9.1