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=unavailable 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 F3A09C43603 for ; Wed, 4 Dec 2019 18:01:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0488206DF for ; Wed, 4 Dec 2019 18:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575482495; bh=eF3P39KjUvxSuIidMSrbztenDOLlfOOshk4nKiXxBZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=L8M61MaCX+5j3hvzoCUC9umNnoJEl+mYbWcvqAoqk/68fR857R6F3YDVmtIe/Cd1b +oA6W9wOwQEtTR+UJ/RpiTJj/OPCSqRgLEf8zciKsOIWkmPKoxZCNw5pj2lfh4fXHH h2Zw+mJiP7f0a5HGbb0XxunkeSqayOZPZ1Qi+Iwo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729616AbfLDSBe (ORCPT ); Wed, 4 Dec 2019 13:01:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:42080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729588AbfLDSBc (ORCPT ); Wed, 4 Dec 2019 13:01:32 -0500 Received: from localhost (unknown [217.68.49.72]) (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 D664320675; Wed, 4 Dec 2019 18:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575482491; bh=eF3P39KjUvxSuIidMSrbztenDOLlfOOshk4nKiXxBZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BOLFm2LfEsrpR6+GcgY1ioCDG45CBySUOFuexbxqiq+nL1BcVadrjQvF7mXZL92vj ArhE63nIu4EQveYGH8ki5644wcUsZFMiGsniceuCuWQU8sFZAQMMYcff/lAq6F+++K u0WI3AjRcUIoQbeVZAMPBnz/G6ms/hesdS9MmKfY= 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 4.14 018/209] can: rx-offload: can_rx_offload_offload_one(): do not increase the skb_queue beyond skb_queue_len_max Date: Wed, 4 Dec 2019 18:53:50 +0100 Message-Id: <20191204175322.793603295@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204175321.609072813@linuxfoundation.org> References: <20191204175321.609072813@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 a2dc3f5e1022a5ede8af9ab89a144f1e69db8636 ] The skb_queue is a linked list, holding the skb to be processed in the next NAPI call. Without this patch, the queue length in can_rx_offload_offload_one() is limited to skb_queue_len_max + 1. As the skb_queue is a linked list, no array or other resources are accessed out-of-bound, however this behaviour is counterintuitive. This patch limits the rx-offload skb_queue length to skb_queue_len_max. Fixes: d254586c3453 ("can: rx-offload: Add support for HW fifo based irq offloading") Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/rx-offload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c index b26987a136203..c0e51a2f8e4fc 100644 --- a/drivers/net/can/rx-offload.c +++ b/drivers/net/can/rx-offload.c @@ -124,7 +124,7 @@ static struct sk_buff *can_rx_offload_offload_one(struct can_rx_offload *offload int ret; /* If queue is full or skb not available, read to discard mailbox */ - if (likely(skb_queue_len(&offload->skb_queue) <= + if (likely(skb_queue_len(&offload->skb_queue) < offload->skb_queue_len_max)) skb = alloc_can_skb(offload->dev, &cf); -- 2.20.1