Received: by 10.213.65.68 with SMTP id h4csp3990588imn; Tue, 10 Apr 2018 07:39:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx49CbXjTeL+I5KyKZRY89FCT3EGGOW1b/3RsT4Vz+vc5APlyF+APnv4F6vwZzzocLNCrtX9h X-Received: by 10.98.202.10 with SMTP id n10mr616049pfg.220.1523371181201; Tue, 10 Apr 2018 07:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523371181; cv=none; d=google.com; s=arc-20160816; b=Znu7Nq0RtjsVd821oi6X0QryHLFnncTQU34FV8I3hnSdYNv4P9lPD/6IHyh3oCdddL WB40zHsS57Xcc10Q4vu0gKTUTsv5YmrXCUnIMZXxCmVbEJfvOwo1TJTRqQ1GnfOv8tf1 +6IWunnjP15okATnZ+c5BAZk3j0eh4WadAdq3vNPYXPoXcmrgczl7naEwkOdgDvecYje zrudPz92SPLT2t9Z5qZfSAP7shMKNNT47+fcCglzwOvuodgXZUl6pywmXKTuXANONcE/ vr1dwwBVmLGhK54yoAKNWjXbGTPPLbB/LN/Zj2Yenk3YwdZjMWFWFPyAggA5hv7yRyTw dFWg== 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=VEtMCuiuiD5QAizEmFFe4i7Y6rquer8HvrqxTo3WhAc=; b=oWlC6u1GgO8aq3JxNZUIppRC94chMWsoeCFMpFO6CbZRClND05vqxjHLUb5y3QcDnw lDlXRM1sS2Gs9sYXeLjCm3Q3z85RpXcdfujbJfyOsfTGMGKtmGIfuqJA1gDmAyeha73t CRLtyjYdN3Yx+UoaHEYTgpsh9wlUbBXBXHHCzN5I9E5QPYyWVUUiCkfqjejWJ3YEX7D4 Nvl/djuwE8Xeldk/UyczqF2WMnv9D87skweNYlC4Y4nXs3FjmzcR2dmCT58NqdKrvlLe HQIVWwYTpzlYf6LTtDEY6OvqUELrXxoQy3NGbs1cCxXa95aeDG9UCClvjTWKRhyzQH5h VwPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Tn72Ej76; 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 g4si2183420pfm.358.2018.04.10.07.39.03; Tue, 10 Apr 2018 07:39:41 -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=Tn72Ej76; 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 S1754206AbeDJOfi (ORCPT + 99 others); Tue, 10 Apr 2018 10:35:38 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:40403 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754182AbeDJOff (ORCPT ); Tue, 10 Apr 2018 10:35:35 -0400 Received: by mail-pl0-f68.google.com with SMTP id x4-v6so7649438pln.7; Tue, 10 Apr 2018 07:35:34 -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=VEtMCuiuiD5QAizEmFFe4i7Y6rquer8HvrqxTo3WhAc=; b=Tn72Ej76QIgOTSE/kyVyjpAiVBYsaYIGeFI9qc+HE0JRDOfKaNTdycy3hWHFCdQK0j F76V0Sp7Vv5RE3ESrysG9Of6iUGJpU+DRshmyGaOm4S+CtzZ+aVdvGPx8uaivUwntThN 0AcZ6AqaiT1X0tBCFOelm/JBK/eBAF9JZHF4obDXpRM9VMeFrEp/xGC9pE8wU9JOUoLr /sDDhbgCbZqKvL6h+xMLCuArCFaDnmD7Be5rR3o7tei5U/sqakRCKC+e+DM1j8nr23Dt nBucSA+qbeQoqVu5laKgmJ4JJEM9Ro1Sl+koyc3HQPqQhofGnnFoHJCzJHrIOVub1irF oZGA== 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=VEtMCuiuiD5QAizEmFFe4i7Y6rquer8HvrqxTo3WhAc=; b=rXYTaX9AqfEqb+OOsoAtG4MKfshdCsS0Pe8yUhQe0J96VLJhxEVVH5ET0ifYNfRvOq vSgSaiSL59495kizsNFbyPKf20541CP2tV13k+uioKxXkMfbMcmqRcRIjEI+QdBybXVW o/IBcR0pbQ67Ocd1o7xFCeWdnUNMa9wq9mqKwQhhOiRRhR18P5Uo5I6miSFxluCkbvFp sCz4qDgAMTfoIiC1EhhrnA0Lf/LSPwj/dzPq6wgUnwOqSgDN/tBl0BxWpk+ER4sZjZaR ZVwn/vFOg5e19AWuMQlq1XxzuLEwrJ0Xe9IkPfZxOb2RjVParQBN8ezTruaQsPIKyn9j H6jA== X-Gm-Message-State: ALQs6tBDlrS5kJEDaYiGprePV679T8LIh+bZRGITQF75bUytm95qHdyY NlUoGxO24VD+OmjpyKJ1FOU= X-Received: by 2002:a17:902:8a94:: with SMTP id p20-v6mr751600plo.94.1523370934644; Tue, 10 Apr 2018 07:35:34 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:8dc7:7954:4991:f324]) by smtp.gmail.com with ESMTPSA id v186sm5571270pfb.182.2018.04.10.07.35.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 07:35:34 -0700 (PDT) From: Jia-Ju Bai To: davem@davemloft.net, andreas@kemnade.info, johan@kernel.org, johannes.berg@intel.com, stephen@networkplumber.org, Linyu.Yuan@alcatel-sbell.com.cn Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] net: usb: hso: Replace GFP_ATOMIC with GFP_KERNEL in hso_create_device Date: Tue, 10 Apr 2018 22:35:24 +0800 Message-Id: <1523370924-32425-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 hso_create_device() is never called in atomic context. The call chains ending up at hso_create_device() are: [1] hso_create_device() <- hso_create_bulk_serial_device() <- hso_probe() [2] hso_create_device() <- hso_create_mux_serial_device() <- hso_probe() [3] hso_create_device() <- hso_create_net_device() <- hso_probe() hso_probe() is set as ".probe" in struct usb_driver, so it is not called in atomic context. Despite never getting called from atomic context, hso_create_device() 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/net/usb/hso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index d7a3379..3d7a33f 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -2332,7 +2332,7 @@ static struct hso_device *hso_create_device(struct usb_interface *intf, { struct hso_device *hso_dev; - hso_dev = kzalloc(sizeof(*hso_dev), GFP_ATOMIC); + hso_dev = kzalloc(sizeof(*hso_dev), GFP_KERNEL); if (!hso_dev) return NULL; -- 1.9.1