Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1495486imm; Fri, 14 Sep 2018 20:13:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYFNzI8qAdrwYEe770p/0g1pxtunsIB2Y36S3PIbNJkivfl6SOW+EM0jkS694tcgv76glOl X-Received: by 2002:a17:902:1745:: with SMTP id i63-v6mr14674199pli.3.1536981222186; Fri, 14 Sep 2018 20:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536981222; cv=none; d=google.com; s=arc-20160816; b=jo/ZKNHoXnreJhkCHy0sR9LBYTe07/ZDxM4xTjB0Q7ZUvcHDswJf7Y5GPHXQAz2v3o 295qwHiP3koMMvf4vkSh0fNQ6gpOK213eiFlGAdyLnxGt8CpcZrF6srEsAJMlb6axO1Y NCGpFoOe4mIaBsRfzcyb7NPFOu2hge7go5QFp6d0BxNVyo8jA66RkENMm9gqqJb4ozRb Z1PQx+oe088RkHFooSVNtPSSIiIUMohO0rlMX9ML42D3PG2D6wHxcmKh65WrrOCGgQqL CTe3GYkj6zrP5k11vxnxC5Niz6HFc0ZQ2WmcOtjo3fiJkQ0aFCHMrG2tzOsUTKZO+6Kw jxIQ== 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; bh=251ZpBy3wzqgLLP+TQhmWnziNpr/7ye8/RmMWmT3hz8=; b=s+jtSa6w9DuRT+VRdNuiZUZ5MCZnQcw42kDBNdAwzEELXPudPxPqmemlLilZr8qWK4 ci1oIV45X7liJ485Px/Jl9jRroLB8DxtAKvdQf5iNJqI86hXWhqq3yI2h1nLSN2fMQbS SoDg/j/Zxyy3bbBzH1nChCNWwldc6nE+LXX/rgc/tbDNbMXTV69XQzTJVMiiaYYUAkn0 OnZnffbdkjJ3GWzNPL8SEBuAUkBEnU+CbXyjUp5G/ahXOwor4MkOdkX6LtuuNgwcPaUf NijtySDCdbLkTgidg9LKkt5RWr+n5q3JWCEMNeQC20IlhxK1/2rK2x2vItra9J5kBmBL 8hcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Q/c9Q+yl"; 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 u9-v6si9001114plk.201.2018.09.14.20.13.25; Fri, 14 Sep 2018 20:13:42 -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="Q/c9Q+yl"; 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 S1727226AbeIOIal (ORCPT + 99 others); Sat, 15 Sep 2018 04:30:41 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37718 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726295AbeIOIal (ORCPT ); Sat, 15 Sep 2018 04:30:41 -0400 Received: by mail-pf1-f196.google.com with SMTP id h69-v6so5115991pfd.4 for ; Fri, 14 Sep 2018 20:13:20 -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=251ZpBy3wzqgLLP+TQhmWnziNpr/7ye8/RmMWmT3hz8=; b=Q/c9Q+ylmTgzzdJMN2DSSQgCtlNGgSKg7pSRWY8oiRJVF4uR8qcXtUbcG9bcc6aYP7 DM0MvdJmijvu0uoiGsNtCquBc3gLHb+x09KlAiOPcB2I9QTm0fmTT12dd/s2lBomV8I2 6thk52pJJy6dmPPA8zrjVF7r6sTr4aRYzf7e7xOXWnZnmeHxLHf0UAirE8Y4bcyW2Rmf /zx8Otukla+UBazc79/Nl5pZYkwNpb9cF8QIKsvncJhYbnMWltTAk4vCEOqqh7WCySJ1 h6mFSLpVw2QrFwgaAR3jkLICZRFUA/F1rlxgGIG2mMUtgTpkYwNmnT9VmPdv4NuCvC79 1ikw== 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=251ZpBy3wzqgLLP+TQhmWnziNpr/7ye8/RmMWmT3hz8=; b=V7l2ukKWJ9QNNboWcyuw/zPbCBPDaaf4dCIIlTpsnnTuH//SfbXv8sQ/3tUtc5G7Xf VlXzkBMlIe2sXk0kwJIgADp67D2dv9FLZOosSoZBRIEvaW8cAJJdbKbgpM8s93CwjoJW ogE1QOISf6BWMuENdxeXJYUI5IJ6TJzZxMT8MEpQTGoaMYoab8ZIPOjzNdiVllsPiDdi pAJX0cVcZSczBXY276qQrkFGLKmhBlpyJ9qphrclksWiMu57WALbYh0h6NUT+phD3LtV 2pK+rif0xwq+cQCfajRTO7VrBN0BXfN7vo88idenLDvjU1Rta/giHoa6OPm1OvlzKeU5 4IMQ== X-Gm-Message-State: APzg51BDgd7dThd9OQUWjpbfX5eCvG+tSCp5QnlLskrL0a5Y3ZyvB3/U Z1/yCdaaNpzaY5GZr0ymzeg= X-Received: by 2002:a63:4283:: with SMTP id p125-v6mr14249003pga.142.1536981200600; Fri, 14 Sep 2018 20:13:20 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:947c:62c0:a59c:7c99]) by smtp.gmail.com with ESMTPSA id y18-v6sm9849594pfl.90.2018.09.14.20.13.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 20:13:20 -0700 (PDT) From: Jia-Ju Bai To: lidza.louina@gmail.com, markh@compro.net, gregkh@linuxfoundation.org Cc: driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] staging: dgnc: Fix a sleep-in-atomic-context bug in cls_assert_modem_signals() Date: Sat, 15 Sep 2018 11:13:03 +0800 Message-Id: <20180915031303.5302-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 The driver may sleep with holding a spinlock. The function call path (from bottom to top) in Linux-4.17 is: [FUNC] usleep_range drivers/staging/dgnc/dgnc_cls.c, 391: usleep_range in cls_assert_modem_signals drivers/staging/dgnc/dgnc_cls.c, 449: cls_assert_modem_signals in cls_copy_data_from_queue_to_uart drivers/staging/dgnc/dgnc_cls.c, 406: _raw_spin_lock_irqsave in cls_copy_data_from_queue_to_uart To fix this bug, usleep_range() is replaced with udelay(). This bug is found by my static analysis tool DSAC. Signed-off-by: Jia-Ju Bai --- drivers/staging/dgnc/dgnc_cls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index 7e6cbfe4e4ee..a1e98ee7f9e0 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -388,7 +388,7 @@ static void cls_assert_modem_signals(struct channel_t *ch) writeb(out, &ch->ch_cls_uart->mcr); /* Give time for the UART to actually drop the signals */ - usleep_range(10, 20); + udelay(20); } static void cls_copy_data_from_queue_to_uart(struct channel_t *ch) -- 2.17.0