Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3651863ybf; Tue, 3 Mar 2020 09:49:30 -0800 (PST) X-Google-Smtp-Source: ADFU+vv4aRezZKMxKDOsGZJoCXN9v0SmR7wZbYZlGMuP3FRv1fo/N8SjbHHcweyQwwrg1C1sXNYq X-Received: by 2002:a05:6808:7dd:: with SMTP id f29mr3318704oij.67.1583257770132; Tue, 03 Mar 2020 09:49:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583257770; cv=none; d=google.com; s=arc-20160816; b=BmIJGfPEdZlBRfsm83/2nPnh0wr9SESUSke0UKd7QG1BOh7GM2MMEk7azVzwSuckd5 ss6C3ERglrG7+UDVjzHAk6cQAnt3DtvFrrJ/YuxtkCVuLj7yJtNqzIEHrf2SNtxROGbh XT/ZkdOHsKgrQB2IMK3qQzOZ/dOkNT4xSajJRQbQraUcuDrafsz7VogBILvdMgLmSLQ2 GWn/Jxw9BA65XhC2YuCurJDRkLrR3Z5QEj0kXj/cE33T5B9Kis2ZC0z4TfunZHqTiIvR HVsQk89n/+5wOFlo0yc4oEVyWkumoVl4NAo1rBhDDXsCgIrxlo4EWcEW7r310JGE9uzb R1uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YwFUgE/uuSvk75zPUIwQn7JH6kiimCcNtC/4Kcit+Zc=; b=f7upwH7xCaRzt7PO6IRylkTkoSlrz5KNf/CognNzdLdy/XJS9EfEEoHxXZ3p27lio/ dfCLP5KUVZ3HEQyF+uMXxwUmokz7YarOQUOQEXqjsBGWyuGvaKP4rIxE6Ll9f0LcJxx8 4UTF2YZWfDTAXVAHQZ/Jj+T5A6sw2ygY7rsp9W4veqv7p1iPm9nTfNQuzKLKCWk1HKHU 2PogHf99yA158byjKnW2STOu4CDlVZNMr8h0487hH+WA9KJsge3hhOmrg8+Aax6HNihl cOzM8ptZYWlYBHhNQBsgECQh62cIuSjI8r2exL4DhPQAysm4MTbnQ54jw4wGHZEwyIf2 w4MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2TBXylbx; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si8583364otn.172.2020.03.03.09.49.18; Tue, 03 Mar 2020 09:49:30 -0800 (PST) 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=@kernel.org header.s=default header.b=2TBXylbx; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730717AbgCCRp5 (ORCPT + 99 others); Tue, 3 Mar 2020 12:45:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:52212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731001AbgCCRpz (ORCPT ); Tue, 3 Mar 2020 12:45:55 -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 785C0215A4; Tue, 3 Mar 2020 17:45:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583257554; bh=lCoIUC5b0pL0VYMsb5nDT4bqv8J5/fmGWMwPjnMO0QM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2TBXylbxcLf9w9JLR8auSgJkJ3RiwreMWboY/mzV+CXqIJoErR3kMrib5hgP5lOXU xLFL+33kK3NWgGr6JlntIW36NM5HZFd5lfLwPpYTQsbWWxbKI0eiNPIkfSYfFcV9jX xkKHF52jTwrBveNSo6qfxairNt0A/QE4pWT9wQsU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Horatiu Vultur , Alexandre Belloni , "David S. Miller" Subject: [PATCH 5.5 005/176] net: mscc: fix in frame extraction Date: Tue, 3 Mar 2020 18:41:09 +0100 Message-Id: <20200303174305.189935639@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174304.593872177@linuxfoundation.org> References: <20200303174304.593872177@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: Horatiu Vultur [ Upstream commit a81541041ceb55bcec9a8bb8ad3482263f0a205a ] Each extracted frame on Ocelot has an IFH. The frame and IFH are extracted by reading chuncks of 4 bytes from a register. In case the IFH and frames were read corretly it would try to read the next frame. In case there are no more frames in the queue, it checks if there were any previous errors and in that case clear the queue. But this check will always succeed also when there are no errors. Because when extracting the IFH the error is checked against 4(number of bytes read) and then the error is set only if the extraction of the frame failed. So in a happy case where there are no errors the err variable is still 4. So it could be a case where after the check that there are no more frames in the queue, a frame will arrive in the queue but because the error is not reseted, it would try to flush the queue. So the frame will be lost. The fix consist in resetting the error after reading the IFH. Signed-off-by: Horatiu Vultur Acked-by: Alexandre Belloni Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mscc/ocelot_board.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/net/ethernet/mscc/ocelot_board.c +++ b/drivers/net/ethernet/mscc/ocelot_board.c @@ -114,6 +114,14 @@ static irqreturn_t ocelot_xtr_irq_handle if (err != 4) break; + /* At this point the IFH was read correctly, so it is safe to + * presume that there is no error. The err needs to be reset + * otherwise a frame could come in CPU queue between the while + * condition and the check for error later on. And in that case + * the new frame is just removed and not processed. + */ + err = 0; + ocelot_parse_ifh(ifh, &info); ocelot_port = ocelot->ports[info.port];