From patchwork Tue Apr 10 13:30:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 10333187 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0478560365 for ; Tue, 10 Apr 2018 13:30:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7098288B4 for ; Tue, 10 Apr 2018 13:30:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBCA728D8E; Tue, 10 Apr 2018 13:30:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89E90288B4 for ; Tue, 10 Apr 2018 13:30:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753978AbeDJNad (ORCPT ); Tue, 10 Apr 2018 09:30:33 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:39151 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753145AbeDJNab (ORCPT ); Tue, 10 Apr 2018 09:30:31 -0400 Received: by mail-pl0-f68.google.com with SMTP id e7-v6so5510856plt.6; Tue, 10 Apr 2018 06:30:30 -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=QW6N6LCHgsf4Arz8AZHxcW+xmno+M4otmLu1qC9JFVk=; b=cjs07uX2hdx+7kGzfHcfBQRk2zO/eLPGuDW9OrQ4AiSKzGDl0hW22VappYugjn7AWH uBXHZ3sjloLQWwfbNr9TywVZAlC35x017Sar77ndAPA2OMUy5SeyUZLuHLDKdFqzECgR n1hpLGebd8JtXlg1C+JkpkZW5A45KuOfs38IHveZyeFILxEx8NQQOD7xFGThADUZTG4W DrMYEZcEbDLzZnGbypmDZfLpe8eQpivVwiqjV9qtKmFS1MKJbpJsti4Bv5dWZo5JXX5J 26dbYIIDkc6n2Ul2qnECi4MTUdcldWuQgGRol/tQfz2PtDiilsjxfWvJHB/rp5ROv6wL V0ag== 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=QW6N6LCHgsf4Arz8AZHxcW+xmno+M4otmLu1qC9JFVk=; b=GtwnuAB3xxDmw2ex8y9szqUqnomgTe/0d28AYZGR2qvtkgoG/fLz5bIs3IpkBITbGc udO6kHTAsIAknW7BNgp/WL4Pcq7ETRS588l5vwfFEU7hHeTM73ONPx05C7fTToTzDkFo dcQIi/4sd8UmKiyKJlOK93IdNcWGpLuGDQrEO2zPeooUSoQT5o1l3lWGDa99yzqE3Olc iQj7e8jc9FfupYlMIQlrEsEbXQkE7msWxW36l+0bhtuVUPoJ8bbIsFutxza2AZgtecsP yxNA6z059brKh8U7QFxA/Ynl1JIJtGt9c2c2PY48L9uHRsq6bI2yw/nudHSOUNmwEyPe /FhQ== X-Gm-Message-State: ALQs6tBxTOJumfsjqf69ibPKnxyME0R4PaX8oplhQ3z2z7cr/zU4+EiE MznVGdE4qVw0i7zeKrZmdzQ= X-Google-Smtp-Source: AIpwx4+KPKhFyhzWdQkyFJ1fMdK5xwwcjvicj1ka3PFmxwowMHJlQAfctwroMLp2sa9IZrHcJ+/7OQ== X-Received: by 2002:a17:902:7b97:: with SMTP id w23-v6mr463387pll.45.1523367030698; Tue, 10 Apr 2018 06:30:30 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:8dc7:7954:4991:f324]) by smtp.gmail.com with ESMTPSA id f12sm5290078pfn.47.2018.04.10.06.30.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 06:30:30 -0700 (PDT) From: Jia-Ju Bai To: kvalo@codeaurora.org, davem@davemloft.net, arvind.yadav.cs@gmail.com, johannes.berg@intel.com, stephen@networkplumber.org Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 2/2] net: wireless: zydas: Replace GFP_ATOMIC with GFP_KERNEL in zd1201_fw_upload Date: Tue, 10 Apr 2018 21:30:23 +0800 Message-Id: <1523367023-31981-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP zd1201_probe() is never called in atomic context. zd1201_fw_upload() is only called by zd1201_probe(), which is only set as ".probe" in struct usb_driver. Despite never getting called from atomic context, zd1201_fw_upload() calls kmalloc() 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/wireless/zydas/zd1201.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/zydas/zd1201.c b/drivers/net/wireless/zydas/zd1201.c index 581e857..cba2bed 100644 --- a/drivers/net/wireless/zydas/zd1201.c +++ b/drivers/net/wireless/zydas/zd1201.c @@ -74,7 +74,7 @@ static int zd1201_fw_upload(struct usb_device *dev, int apfw) data = fw_entry->data; len = fw_entry->size; - buf = kmalloc(1024, GFP_ATOMIC); + buf = kmalloc(1024, GFP_KERNEL); if (!buf) { err = -ENOMEM; goto exit;