Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3739627imm; Mon, 30 Jul 2018 02:34:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpchTXuYcLQpclR+22gyqO4VfjZVpnpHFaL36eGoflwHe5xmkm7LfcYpxE5y36LatZ70L4Uf X-Received: by 2002:a17:902:8506:: with SMTP id bj6-v6mr15546322plb.210.1532943277568; Mon, 30 Jul 2018 02:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532943277; cv=none; d=google.com; s=arc-20160816; b=nX+RiY3rctXp2N52grrMAOvvMdEqCJRQB5RrX4dreBw2FzKjrcsTe4hwHa9FYJ0o+H NVaKv9uJbS3Vn5XH5+FH6Lr+lf+5AjIqLRVvZqdWx0XT7BXFOTFygJn/mXbRSf+o/WjB 35zYeU8uC5AiM4nr0qUwD5hgNJTD15Clj5Zuukc/5oH/cSB1HAdygKO5NTivOCVmDu8/ x724iueRZDT/fcKSCcoD2lAU6r/cxwT5iE4oDtzQ4P9NQZBMOjZW8xuTJFD0FVMiaIqY nXPWbd5nxWJrLx6zetLvHiLggllOJs1BeKgdFBySTD592wMyWZgVZcB+jEnpBhlApHIg /7pw== 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=C0qdcMQ4xD0ood1tgWz95bY+LNq+sNtaiH+ZmrcF3Io=; b=pR5UkizC2Qi3rPS2rCGarQp0P5jmBnby8m8hD+iLxQP2DhXmMdqYVMhx4P7oS4n4GJ +EJyViPYXas59dQISy7udjm3ffQGnnTxbZOCqDmZIOZ1KQPBfcFWsz/KErXDkZ5OAfVg eLCKGEbub6+I2elVDeYrtek/ZaIQZWvxkQgaozR06WzjIJR/NBCKvW7HcjTHOoyeqbGk i+HjHV+7Ta4Q1PJT+9X7f876PXjz2AdCrDUz74kxwcmcLV/9/YY0uNoOdHCEIom2Zm+F 7h5OlIC6thwlyLQMbflwTCktCnJFreClBiMGPUixppRFEJefctk2Q7vkKPzKiMAs28Ta I+jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=abWD5YAg; 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 t191-v6si10914543pgc.481.2018.07.30.02.34.22; Mon, 30 Jul 2018 02:34:37 -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=abWD5YAg; 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 S1726906AbeG3LHi (ORCPT + 99 others); Mon, 30 Jul 2018 07:07:38 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41223 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726705AbeG3LHi (ORCPT ); Mon, 30 Jul 2018 07:07:38 -0400 Received: by mail-pf1-f195.google.com with SMTP id y10-v6so4275656pfn.8; Mon, 30 Jul 2018 02:33:31 -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=C0qdcMQ4xD0ood1tgWz95bY+LNq+sNtaiH+ZmrcF3Io=; b=abWD5YAg1HWjw9UJ4GtFiFNWgpXVwT2qp37azHW86k9zu9IrQjlZ+GKtTKOdiuXCcj K1gH471u3gkIGYWI2vVGRDhlWoPEGJLlCIiOCHHTYyoYGPco/sqjbv2pUQtp5fS6BRsj S4ur9QlWL2x+bimT+iEJjFt88RhsZ6dl2S666zSwJ1SONoi3CPgcYnkgDf811qi3Jyin jAA+umWsehFfB6Tctnq8kWuat7iyjyT4rRLgHZrqjHWR8sfZcgVKcmubulRWHLKW5YC5 2AimQhF1VDRd7DbkX9bkncGU+qkxMclL47CsYfKTd4/ZvpApLyqgkl/F1F7LGx8SY4zv +yDg== 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=C0qdcMQ4xD0ood1tgWz95bY+LNq+sNtaiH+ZmrcF3Io=; b=Lv3XXVIMbMRuGCesEpTrfcUNeb/ptFRgIFgqBhfdnjynPPwF8mColF4Qct/QFFUdOt MSe6U1DK65Hv7oRlbz5/T0hs+jaZhn25e9s6XUEjx5QioJ+K/DsE6Hx9GZDZzHrtyZhR Hm+4Y3CMwVKCNOU11oiSuWlM4OcjdY3O7Ex1wOtEyVl9qMqUUAIYWWv5ve8fK+A4zrFj DIU/qILP2eQ9QG7oRkIcFzBobCuRWGoJTwQpFLZ81V3SpDXf76DyrwrRDPEtX+eBUh0O 655ZeA6qrmuBCLWU8l9UR9nIUj7e8nI0iUAHraMxZ4uHPvXOyygYXlgSpeFHU50VDYis g7FQ== X-Gm-Message-State: AOUpUlE/N30W8nJL8l1CV8+ZaLOnOaUcBJuTOoMVCNIsQgdmR/SWtwca LJl0tvmh4p9bnxvgFZAr8mI= X-Received: by 2002:a62:1756:: with SMTP id 83-v6mr1089883pfx.217.1532943210759; Mon, 30 Jul 2018 02:33:30 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:4550:ab75:cee3:d6c1]) by smtp.gmail.com with ESMTPSA id v22-v6sm27419868pfi.60.2018.07.30.02.33.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 02:33:30 -0700 (PDT) From: Jia-Ju Bai To: crope@iki.fi, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] media: usb: hackrf: Replace GFP_ATOMIC with GFP_KERNEL Date: Mon, 30 Jul 2018 17:33:20 +0800 Message-Id: <20180730093320.8007-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hackrf_submit_urbs(), hackrf_alloc_stream_bufs() and hackrf_alloc_urbs() are never called in atomic context. They call usb_submit_urb(), usb_alloc_coherent() and usb_alloc_urb() with GFP_ATOMIC, which is not necessary. GFP_ATOMIC can be replaced with GFP_KERNEL. This is found by a static analysis tool named DCNS written by myself. Signed-off-by: Jia-Ju Bai --- drivers/media/usb/hackrf/hackrf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c index 7eb53517a82f..520a3c6dee43 100644 --- a/drivers/media/usb/hackrf/hackrf.c +++ b/drivers/media/usb/hackrf/hackrf.c @@ -597,7 +597,7 @@ static int hackrf_submit_urbs(struct hackrf_dev *dev) for (i = 0; i < dev->urbs_initialized; i++) { dev_dbg(dev->dev, "submit urb=%d\n", i); - ret = usb_submit_urb(dev->urb_list[i], GFP_ATOMIC); + ret = usb_submit_urb(dev->urb_list[i], GFP_KERNEL); if (ret) { dev_err(dev->dev, "Could not submit URB no. %d - get them all back\n", i); @@ -636,7 +636,7 @@ static int hackrf_alloc_stream_bufs(struct hackrf_dev *dev) for (dev->buf_num = 0; dev->buf_num < MAX_BULK_BUFS; dev->buf_num++) { dev->buf_list[dev->buf_num] = usb_alloc_coherent(dev->udev, - BULK_BUFFER_SIZE, GFP_ATOMIC, + BULK_BUFFER_SIZE, GFP_KERNEL, &dev->dma_addr[dev->buf_num]); if (!dev->buf_list[dev->buf_num]) { dev_dbg(dev->dev, "alloc buf=%d failed\n", @@ -689,7 +689,7 @@ static int hackrf_alloc_urbs(struct hackrf_dev *dev, bool rcv) /* allocate the URBs */ for (i = 0; i < MAX_BULK_BUFS; i++) { dev_dbg(dev->dev, "alloc urb=%d\n", i); - dev->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC); + dev->urb_list[i] = usb_alloc_urb(0, GFP_KERNEL); if (!dev->urb_list[i]) { for (j = 0; j < i; j++) usb_free_urb(dev->urb_list[j]); -- 2.17.0