Received: by 10.192.165.156 with SMTP id m28csp229367imm; Tue, 10 Apr 2018 20:27:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/wFHpFJW6NtHV9hr4hrebvyuHg2U/z+oZwYle39OgQLlplgDpSaI4c8+jVvfFhL1sQXdAG X-Received: by 10.98.35.90 with SMTP id j87mr2522389pfj.59.1523417273392; Tue, 10 Apr 2018 20:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523417273; cv=none; d=google.com; s=arc-20160816; b=LL6QD1/qkitw4eEZMrB/BLzQDLhkISW9UloIaH5az4YWyyjfxhKpjtE/pFCE3K7QAb ylD1qDEOqCOsWUCxePg8yHyNifxyf5OK+GHWqh43ubc6Rkmxwb0w9WJeaF36e/fJjRSM 3qTkPzyTwccsfM9dnhkDgvQONZBqYXDaxkHlvUsPrRxoEKuKrYF2MUlokisVULvpOCue fTapdX1rCrbc8KAPXlW5upSGszrC9MySETPEIltMJhQ0mQWk0G4nNbxZ8xGYMYpVGfvb Cz2Z5Y2f+gFWyEs7EA1mcLNzc+BQiU9fU317/IKumleF6FSDp+q/bqMeGZ2k5MtaEJUH F5nQ== 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=5sXM65TnOuMDDDfR/XB5yxG1+yU2ccJljOPxOCyC1xk=; b=AEOv0iLQDwUJJFrbxPx6fp0ewfoI9srzJ8he52aeF4M1NiDsgCvxs8RdLRj8EKY19M okVAup7GvREE46BrvGsOLHOlIoyJ6ObmzLYQhsQR7TcDYoFMe8julCAtEd3SmZZVzcjv /3sbK4iTXGDOKUFgA1p0pJLvT+Pyrdd2jt0pF10BRfpINwoq1cNpaQ4qfW8j7kUin8Go UFK9h0CBetLNv+l7nJryiYKdNsxC5ZD8WWz8FP+ynZTvKxwz158cNOgmXelWQIkJ54Sd ZSFxcYB0FVFXVUA84hNsdy/v5awEDdr3KApWD5gtSQ415jFSIQsY5tIIERZRrNkwIhU6 bkbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m4pfaFPG; 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 e4si161974pfb.204.2018.04.10.20.27.16; Tue, 10 Apr 2018 20:27:53 -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=m4pfaFPG; 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 S1752796AbeDKDYN (ORCPT + 99 others); Tue, 10 Apr 2018 23:24:13 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:45221 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752103AbeDKDYL (ORCPT ); Tue, 10 Apr 2018 23:24:11 -0400 Received: by mail-pg0-f65.google.com with SMTP id y63so141584pgy.12; Tue, 10 Apr 2018 20:24:11 -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=5sXM65TnOuMDDDfR/XB5yxG1+yU2ccJljOPxOCyC1xk=; b=m4pfaFPG9Za4tfoDTYWDldTiUAetvnG4USlmILEss9Z1Xz/z8skv7/7MJlDitVSwU+ y5/2ocJO3RiyLNZharf55myO5yv/TucZgk+JI3d3Hna6iq7SEk/xzycsJTNbpjhwMJX3 5R/L/7Wiui1o2O6lLb2MvEbwoHGwWeHyi0YuVJLO0gm9MjLOPxUAhKN86/735km6XCet 6WFFCwupemZ/brSnthU6r2g0+y7ssUK8rtWFp1BUzlJA4gOD2n/9pZISfElKcD3atkBt DJ0P5MskZtcVI1sE/jHg73ND70QVKHNSJcHyR0vhYl7zXYZYC7+irGJt2iCnLWR56yxk Tw0w== 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=5sXM65TnOuMDDDfR/XB5yxG1+yU2ccJljOPxOCyC1xk=; b=MEq7+0xe4gBx8mJL36j3xryUu1cx7jI9GuEfWfKnigqqnPJmMlZ3z3M9j88E84pxIf ztV5tq7en1Nkp/EEUj8ZrIQ3/eUrKBDiU0NrhqrhBrekAPoxVne7mBCLsQ2mAg+HdLaT CsDF/xlmmG4ph/8XutzIj8l9KjQx7pGFiguiVgchavsh049Q10+nQ+sTlfMem+vIPs7B VNVGIjR5HfrFuEtBj4mDX6GgClL5AX+0NjnjJOjxQDBVG87Z9OW86pByM8Ra2X1xONnW 9SKSicYzG6bQhHbCc0kgSrhOMszuvNAAfUSFU4w+J25Q2a+maIzTbUlzxNapYp3RsLqj Z+Aw== X-Gm-Message-State: ALQs6tAXH82oDV9TneozBX3TDvSqJ+5ofB1dL45NMn23tllato65dv6E s79jYAUST6Mn4bXudGfzX04/xlgf X-Received: by 10.101.100.132 with SMTP id e4mr2162577pgv.240.1523417051288; Tue, 10 Apr 2018 20:24:11 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:edc8:c1dd:b0a8:461d]) by smtp.gmail.com with ESMTPSA id x76sm281728pfi.151.2018.04.10.20.24.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 20:24:10 -0700 (PDT) From: Jia-Ju Bai To: mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 2/3] media: dvb-usb: Replace GFP_ATOMIC with GFP_KERNEL in usb_bulk_urb_init Date: Wed, 11 Apr 2018 11:24:04 +0800 Message-Id: <1523417044-3115-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 usb_bulk_urb_init() is never called in atomic context. The call chains ending up at usb_bulk_urb_init() are: [1] usb_bulk_urb_init() <- usb_urb_init() <- dvb_usb_adapter_stream_init() <- dvb_usb_adapter_init <- dvb_usb_init() <- dvb_usb_device_init() <- xxx_probe() xxx_probe including ttusb2_probe, vp7045_usb_probe, a800_probe, and so on. These xxx_probe() functions are set as ".probe" in struct usb_driver. And these functions are not called in atomic context. Despite never getting called from atomic context, usb_bulk_urb_init() calls usb_alloc_urb() 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/media/usb/dvb-usb/usb-urb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/dvb-usb/usb-urb.c b/drivers/media/usb/dvb-usb/usb-urb.c index 8917360..d6d62e8 100644 --- a/drivers/media/usb/dvb-usb/usb-urb.c +++ b/drivers/media/usb/dvb-usb/usb-urb.c @@ -144,7 +144,7 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream) /* allocate the URBs */ for (i = 0; i < stream->props.count; i++) { - stream->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC); + stream->urb_list[i] = usb_alloc_urb(0, GFP_KERNEL); if (!stream->urb_list[i]) { deb_mem("not enough memory for urb_alloc_urb!.\n"); for (j = 0; j < i; j++) -- 1.9.1