From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2F53C432C3 for ; Tue, 3 Dec 2019 22:41:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 881CC206EC for ; Tue, 3 Dec 2019 22:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575412900; bh=rU29GQKb3JthhKJVz13Cku6tYwkfIafBv+cnoeqH27E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Og96YfPQUTYOkV2KmX/Y7dyOVlurzfbwUdCXAax66FC1Bay+vr406X2JQdfH4sKfn 9VKP6pk8hCo+PLdvvPw2ZzDF5GA0gqmEHdjF//gSIfu5NOvJNZQHcAqosZMNogC9u6 uXhrYkRIwTVMz2ClfJna3nNUu+yIQCP982Go3StI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728573AbfLCWlj (ORCPT ); Tue, 3 Dec 2019 17:41:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:56042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727981AbfLCWle (ORCPT ); Tue, 3 Dec 2019 17:41:34 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1650820684; Tue, 3 Dec 2019 22:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575412893; bh=rU29GQKb3JthhKJVz13Cku6tYwkfIafBv+cnoeqH27E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ynky+d2g2CIYcBd7QNblCDB6czpCMh8eAyNRj1i+7wmh4Zi/ZDX4dQNv5FdeUydiG lVUKC2Sn3a1Vn1A7pqSCh+539wzMLKvAd21Lo+dN8UYrYWu1osc5ib9aT1CGBsKIye RaQEk19+GZIiP9orqsp7dcXKJxcUslxxtbqHNto8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.3 058/135] can: rx-offload: can_rx_offload_irq_offload_fifo(): continue on error Date: Tue, 3 Dec 2019 23:34:58 +0100 Message-Id: <20191203213021.202307197@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203213005.828543156@linuxfoundation.org> References: <20191203213005.828543156@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Kleine-Budde [ Upstream commit 1f7f504dcd9d1262437bdcf4fa071e41dec1af03 ] In case of a resource shortage, i.e. the rx_offload queue will overflow or a skb fails to be allocated (due to OOM), can_rx_offload_offload_one() will call mailbox_read() to discard the mailbox and return an ERR_PTR. If the hardware FIFO is empty can_rx_offload_offload_one() will return NULL. In case a CAN frame was read from the hardware, can_rx_offload_offload_one() returns the skb containing it. Without this patch can_rx_offload_irq_offload_fifo() bails out if no skb returned, regardless of the reason. Similar to can_rx_offload_irq_offload_timestamp() in case of a resource shortage the whole FIFO should be discarded, to avoid an IRQ storm and give the system some time to recover. However if the FIFO is empty the loop can be left. With this patch the loop is left in case of empty FIFO, but not on errors. Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/rx-offload.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c index 2ea8676579a9c..84cae167e42f6 100644 --- a/drivers/net/can/rx-offload.c +++ b/drivers/net/can/rx-offload.c @@ -248,7 +248,9 @@ int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload) while (1) { skb = can_rx_offload_offload_one(offload, 0); - if (IS_ERR_OR_NULL(skb)) + if (IS_ERR(skb)) + continue; + if (!skb) break; skb_queue_tail(&offload->skb_queue, skb); -- 2.20.1