Received: by 10.192.165.156 with SMTP id m28csp230228imm; Tue, 10 Apr 2018 20:29:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx493TBbExbeGxNF0rLwjXqlEpndbmEwn0nuxVv0yYai4QmkIb0fZwhBe5CpBjljMvk3Yz5ae X-Received: by 10.98.12.140 with SMTP id 12mr2503720pfm.123.1523417353146; Tue, 10 Apr 2018 20:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523417353; cv=none; d=google.com; s=arc-20160816; b=QpqURu22VeXziq5wN1z37gGgV4t6t1UvcKTH7lcPVU31GXmJipNcIlfaV/Bkgr0aFo dlb/ZJp4fHWYl6dbzr+CZSOmJF47dUP5TctGpMbWsfGn1dJmEjYlz20qIALtByZtDmne szXIMsIg5uOZM1SVYcDIz0r7Piu35fwdfAb6bGrh5hDfQiDtuIi6zyms+iCniBK3CdJE hw1qz3p497UMlBQlgAGrq7zHdwavgli3L8F2tYUc5Kk8d17Bi6tRO+U/csx64d8cVbuI P5jbDeAtA1btqUAAbFNrGHrD2VgC1jwX5yYzfMiWeetxlydwVia5Th3BFSu3JRN4DOxr haWw== 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=CTVxJN9mYWYG9uqkTqzcjBrPY74zmkZBZDqhvYq4qHw=; b=VTuKkwE2ZZsTAk4Xf/XrDtS/VmVGBr4CebTSMeHYtLOhykCH6Og6iq38tgTWwLs1YY Mmr0lzEPwTcuqQE3J6ibKTu8tO0Z4zeGoyFxqbu5uTS+kiLyNE8aZtfupFtgvmKjoTNr PE4/EPPl05PX5TFltDuxsKtNsKeTeoiOfDGR2sQPgHcCkpTVrE+lYuCipF8k9tZg4Vfx xXl1xyuzyqrW+v0DFYu7b+wtF9b9gjVD9czJwONUm3GIqrcY8EArIzgZnh68TM1SdJay Y50Tozqx+2D3fES34TJhr/s9zyw5xMKFB0z1slfds3qjzsv1U9+IgNC4C4xsU+0j2cOG T29g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hokk0KXt; 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 m14si142073pfk.201.2018.04.10.20.28.36; Tue, 10 Apr 2018 20:29:13 -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=hokk0KXt; 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 S1752860AbeDKDYc (ORCPT + 99 others); Tue, 10 Apr 2018 23:24:32 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:42277 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752103AbeDKDYa (ORCPT ); Tue, 10 Apr 2018 23:24:30 -0400 Received: by mail-pg0-f67.google.com with SMTP id e12so141442pgn.9; Tue, 10 Apr 2018 20:24: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=CTVxJN9mYWYG9uqkTqzcjBrPY74zmkZBZDqhvYq4qHw=; b=hokk0KXtn8Jtfbq2EudbeJM0gwHKhdSR3Ref+XZ2GVs3oBJO5RUQBA3dKscu66GldG 1wdx8nfwQYXYUcghqpljYimRxj77gBTc9+3Pl1gkRdSTqQAtBZvfU2Ub57BStwtVHL3D jn8QJpI+LVs8IR9xNoiH7IOZsKIaIomyT/XDaW0qYdI09Tso8c2kSS8Do+3lpfT/Avg4 pfcsWlmtg0RDmTYr00NliafjT9uD4g7N/xGDu8gcvpEjEw8gzzTAYnhRHOdZZiDxOrDi 2Pb0Aqh1N2aFKtO6oBy3zmnl6gfAnglmK/L4rOocMgnHsyivn6/Q6JWeqUOtekiTLo1C aYgw== 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=CTVxJN9mYWYG9uqkTqzcjBrPY74zmkZBZDqhvYq4qHw=; b=mW1HyDjrxpMUljQet04yxjGTPwOEUS/nlbhxd1oqErebQocPG81AIYoO11xYsujZct fb0AFgoT/YmF2dtCSnTgjhS1lcY5WkiVVoRN6/1pul1L1TUvG0l9zJL+KqSUtYZ1mA45 e6eevgJ07FDI+PaQIxpK183W5RELPsh7YD8wa6IiiAtcrDkm/Z7pP/qh6xMzxJshG8gJ RtY3lnxtqvS4dEdf2Gg7Bfk4p1/zJogBC5vUswOodxB0Z/i3Z6eJoZhZ0xzhZhV1P0bq ij9y1uZ+k+Xu+8hHPuxtAjati2Y+UwVtnqkuNpFnJR5vdSsQIm5jnHdUZEOgdLkjwdpX LrDg== X-Gm-Message-State: ALQs6tAWfkoJCuw05dsfyaG+4zqmt/i0j4PVzfKArn0dUMNcFNCHTaIJ slU7qn5S6h1QG5dE/JHKyvg= X-Received: by 10.98.224.215 with SMTP id d84mr2482410pfm.23.1523417069828; Tue, 10 Apr 2018 20:24:29 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:edc8:c1dd:b0a8:461d]) by smtp.gmail.com with ESMTPSA id x128sm231210pgb.31.2018.04.10.20.24.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 20:24:29 -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 3/3] media: dvb-usb: Replace GFP_ATOMIC with GFP_KERNEL in usb_isoc_urb_init Date: Wed, 11 Apr 2018 11:24:18 +0800 Message-Id: <1523417058-3161-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_isoc_urb_init() is never called in atomic context. The call chains ending up at usb_isoc_urb_init() are: [1] usb_isoc_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_isoc_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..1efa4bd5 100644 --- a/drivers/media/usb/dvb-usb/usb-urb.c +++ b/drivers/media/usb/dvb-usb/usb-urb.c @@ -177,7 +177,7 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) struct urb *urb; int frame_offset = 0; - stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, GFP_ATOMIC); + stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, 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