From patchwork Fri Jan 24 09:32:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 232878 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 96AAEC2D0DB for ; Fri, 24 Jan 2020 11:34:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6372822527 for ; Fri, 24 Jan 2020 11:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579865695; bh=o5UBPS4PzJndnqyFENeG0rQ9LWhNSKEmr6Ed1xVO4Ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sUwiuSxzBxvBy9vHeG0koXHuvwr3Yy3f+TyqffUwY2x18aIcy3oCrRR/VLlJMOLnR Ph991sXyaB4cUpjbtHHWm9Wn77r7CKNt0CplBDE83sl4r8FrXrR6994klSOu5G3bux ApNKvVS3D5kSJsqRtIoW0xAPkFkOEt2Xtzmzb7L4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404586AbgAXLey (ORCPT ); Fri, 24 Jan 2020 06:34:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:52296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404538AbgAXLdB (ORCPT ); Fri, 24 Jan 2020 06:33:01 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (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 D102020704; Fri, 24 Jan 2020 11:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579865581; bh=o5UBPS4PzJndnqyFENeG0rQ9LWhNSKEmr6Ed1xVO4Ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZQzNWJCJGnYLjTFlCanvKwNe86UlemtoT5O3JEPhsnnbt/JGyGdonDTCS0xDz28m EzdKaY+QV5UaN6liQe6uTD3TItkEhSq5Oz4SJf5qLgfQstptExLD48hPVJVDEW/mIW RtuCvajqVU2DreKHSqDZg765Qo3q558fXA0nOkgM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Vinicius Costa Gomes , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 585/639] net: sched: cbs: Avoid division by zero when calculating the port rate Date: Fri, 24 Jan 2020 10:32:35 +0100 Message-Id: <20200124093202.761623028@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vladimir Oltean [ Upstream commit 83c8c3cf45163f0c823db37be6ab04dfcf8ac751 ] As explained in the "net: sched: taprio: Avoid division by zero on invalid link speed" commit, it is legal for the ethtool API to return zero as a link speed. So guard against it to ensure we don't perform a division by zero in kernel. Fixes: e0a7683d30e9 ("net/sched: cbs: fix port_rate miscalculation") Signed-off-by: Vladimir Oltean Acked-by: Vinicius Costa Gomes Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/sch_cbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c index 289f66b9238d3..940e72d6db185 100644 --- a/net/sched/sch_cbs.c +++ b/net/sched/sch_cbs.c @@ -310,7 +310,7 @@ static void cbs_set_port_rate(struct net_device *dev, struct cbs_sched_data *q) if (err < 0) goto skip; - if (ecmd.base.speed != SPEED_UNKNOWN) + if (ecmd.base.speed && ecmd.base.speed != SPEED_UNKNOWN) speed = ecmd.base.speed; skip: