Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1526569imm; Fri, 14 Sep 2018 21:07:20 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdaxi1PKJ8fZ3Ir1GVfP5fPtiNf7rfZwtRQxVTJAyktV3oGEnu/dCxVOWgE8bc5i5z3Ew7NF X-Received: by 2002:a62:401:: with SMTP id 1-v6mr15247815pfe.28.1536984440717; Fri, 14 Sep 2018 21:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536984440; cv=none; d=google.com; s=arc-20160816; b=B81j3Y4hoLX9izThLCFbaZhY00gi/BReLdo+uQBD9RN82x6xHXOfROWaN7SxjvL+Jh oZg7E8nhFtvJSUxNAQnQp8zmluzrQvy4LgQykY2RdnXmX4HUCrL3A5iNUMbZekilcMMP f52VJhQuC7Wcmcgjx9vOjCnn87OlhKKssJ6togPGJDwoQjTKVOycs0crd1iA4Lf5ASU6 OhITp4dj4+k9NP8IFiV+QUNm2PmAWcDDMq4bAMm2aJRKeQKqbQ3eCZb2czIWD2WKXNB/ V2LeV20XsIXGj0bkr39+FUmgZw/mtLX+CxgYr5vdKmoT1Kg2Rh/Oj/rPYbqacfMy8a9N Muow== 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=ypZH1fqiIN6FCUM/Eys54o238UT3dDOHuvv9WEvDJoY=; b=HU4VkGbiDmXtppQgHEzqz5HueEEo3Gt+v9MDh9UidU169y4FNGq3AwzQicP/kUdruL VyZ5EECvbThiOqDNRyTIEKOrmptKXbIpKfKbCcDtItQSf2UW09V1bAgFl+BJ7dFhw1UJ UyzRGjma5yXTsstsIDw0lJ3YgKgXg7Bq9DaWDN6CSQbWeTcEDf21ZwEDzI1w4QKypFik ohAqaLdn4Ri5kVWtHH7GNdkMl/lZRxT0fFXKGigzEyhTTQ+LwoxKXnZuvunEVXm1fNvN XG4T+yyb2e2+ens8MCxJ0VcgLJ9Y8jck7I5oG94lLQ4zJPTmtPP8GcchsOnirh3sKukB yPiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OKMqdGm4; 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 n13-v6si9701416pfd.50.2018.09.14.21.07.03; Fri, 14 Sep 2018 21:07:20 -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=OKMqdGm4; 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 S1726806AbeIOJY2 (ORCPT + 99 others); Sat, 15 Sep 2018 05:24:28 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38665 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725796AbeIOJY2 (ORCPT ); Sat, 15 Sep 2018 05:24:28 -0400 Received: by mail-pf1-f193.google.com with SMTP id x17-v6so5154881pfh.5; Fri, 14 Sep 2018 21:06:59 -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=ypZH1fqiIN6FCUM/Eys54o238UT3dDOHuvv9WEvDJoY=; b=OKMqdGm4bwq5n1dx8NCZXY5eV/Yw+kgywF1bzUiE70p7hmN/mmTaobAhH5tsFrEQ8H ptHl1pttOK9nnfCnegN9nvTZr23+zjSiZ0kwW2vI+svQpydMwUciRPEoepIOthCOIv8z MZFYlEOAqLnsgp6D66pSTlJbmfmG+yCXxKp5neAhoSrpPkTXNrKEMDEqw3oiNvQc7hs1 NLSbOYmxmwYNMa9ML2ek+5gFkQPwm+L3p1XhV31awTaBGwS5FXnn7puluy29+sJ3hcOk wM22TIzsjXyc573yBw9g3NgPrV/lfihUodIW6+2r2CscJ0yKgfYhYkTBNmfa8iffdWG8 EfIQ== 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=ypZH1fqiIN6FCUM/Eys54o238UT3dDOHuvv9WEvDJoY=; b=NbfpE6aawo+G0/gBe66VmVsn6jK0UG1/E9VPPCOgSNxI3BBycFr+LCHWXpaM7/gsMG EibwZPYg8/lsnmjY7ucTwT3AYFUuTO5j6LXWr0JCcrejiiQxyms2AL5P5TeFqIh+q8SM gOKwNCGvvRNUgRyLrJWwcQh4mYPN+Qt+pzxlVLR41mYe0sUs/wwZv7TEa3ZyJyzd/vGP MLowv47JuucqRF8jtT6pbtDE1OGW3QmywfuAVn95SxLi6ZWveyZPPIyS8lCfATL9uTru 4cJ1BD0G1L1CuMEmmZxoJTK8lQlfs02SUy9/XooWIsawtc7jYSaxA3K4PPc5Tq9AwJ39 RYTg== X-Gm-Message-State: APzg51AXDT1mZydNwtjX4Tw2qNNqHcuZP3/OW9B6L1jFb104N1OFhGf6 lh3gMCtYJl/XIezAyRjw6Ys= X-Received: by 2002:a62:205d:: with SMTP id g90-v6mr15567169pfg.253.1536984419499; Fri, 14 Sep 2018 21:06:59 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:947c:62c0:a59c:7c99]) by smtp.gmail.com with ESMTPSA id k126-v6sm11544016pgk.26.2018.09.14.21.06.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 21:06:58 -0700 (PDT) From: Jia-Ju Bai To: davem@davemloft.net, hayashi.kunihiko@socionext.com, yamada.masahiro@socionext.com, robh@kernel.org, andrew@lunn.ch Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] net: socionext: Fix two sleep-in-atomic-context bugs in ave_rxfifo_reset() Date: Sat, 15 Sep 2018 12:02:46 +0800 Message-Id: <20180915040246.22703-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 paths (from bottom to top) in Linux-4.17 are: [FUNC] usleep_range drivers/net/ethernet/socionext/sni_ave.c, 892: usleep_range in ave_rxfifo_reset drivers/net/ethernet/socionext/sni_ave.c, 932: ave_rxfifo_reset in ave_irq_handler [FUNC] usleep_range drivers/net/ethernet/socionext/sni_ave.c, 888: usleep_range in ave_rxfifo_reset drivers/net/ethernet/socionext/sni_ave.c, 932: ave_rxfifo_reset in ave_irq_handler To fix these bugs, usleep_range() is replaced with udelay(). These bugs are found by my static analysis tool DSAC. Signed-off-by: Jia-Ju Bai --- drivers/net/ethernet/socionext/sni_ave.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c index f7ecceeb1e28..3c784a29ce0d 100644 --- a/drivers/net/ethernet/socionext/sni_ave.c +++ b/drivers/net/ethernet/socionext/sni_ave.c @@ -904,11 +904,11 @@ static void ave_rxfifo_reset(struct net_device *ndev) /* assert reset */ writel(AVE_GRR_RXFFR, priv->base + AVE_GRR); - usleep_range(40, 50); + udelay(50); /* negate reset */ writel(0, priv->base + AVE_GRR); - usleep_range(10, 20); + udelay(20); /* negate interrupt status */ writel(AVE_GI_RXOVF, priv->base + AVE_GISR); -- 2.17.0