From nobody Fri Nov 29 02:39:06 2024 Received: from MSK-MAILEDGE.securitycode.ru (msk-mailedge.securitycode.ru [195.133.217.143]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C690B187349; Wed, 25 Sep 2024 13:51:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.133.217.143 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727272309; cv=none; b=g9uRcHF2qD2P26rhVQcbjeh5iqurIjqJ2fRKOGBsbwvgyif13zP3mAkEX08QnACUwaoZNA58Fb1uFBc8K1ouGstb8+HeA95sr4P16GUiouY47JDrq1lhJpMwFLfLL1XzkmRgmz2NPJ0dvLiP3u3fPpaHq8ls3hOZz8GAFLxxoJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727272309; c=relaxed/simple; bh=LJMspkkmkJNMuzldXg0HbzppHr8ThVXxB8kGMLh1ytY=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=vFotEizjqZS/woZ4kZXrnRPn7+DyMJU4gJ8HweEZAK9zyeTbdobSAIF5p3Mi0RqGQDNRrTARYBZ7iOj963xem+pFNXsGMKCQgOxFa7KkHkCezRXtTkEXSlyI16MheXzoANOr2+OzxeGj3ZEXkXPHcZnYdFjQOayNvr4VWgcDiF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=securitycode.ru; spf=pass smtp.mailfrom=securitycode.ru; arc=none smtp.client-ip=195.133.217.143 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=securitycode.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=securitycode.ru From: George Rurikov To: Heiner Kallweit CC: George Rurikov , , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , , , Subject: [PATCH] r8169: Potential divizion by zero in rtl_set_coalesce() Date: Wed, 25 Sep 2024 16:51:06 +0300 Message-ID: <20240925135106.2084111-1-g.ryurikov@securitycode.ru> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-ClientProxiedBy: SPB-EX1.Securitycode.ru (172.16.24.91) To MSK-EX2.Securitycode.ru (172.17.8.92) Variable 'scale', whose possible value set allows a zero value in a check at r8169_main.c:2014, is used as a denominator at r8169_main.c:2040 and r8169_main.c:2042. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 2815b30535a0 ("r8169: merge scale for tx and rx irq coalescing") Cc: stable@vger.kernel.org Signed-off-by: George Rurikov --- drivers/net/ethernet/realtek/r8169_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethern= et/realtek/r8169_main.c index 45ac8befba29..b97e68cfcfad 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -2011,7 +2011,7 @@ static int rtl_set_coalesce(struct net_device *dev, coal_usec_max =3D max(ec->rx_coalesce_usecs, ec->tx_coalesce_usecs); scale =3D rtl_coalesce_choose_scale(tp, coal_usec_max, &cp01); - if (scale < 0) + if (scale <=3D 0) return scale; /* Accept max_frames=3D1 we returned in rtl_get_coalesce. Accept it -- 2.34.1 =D0=97=D0=B0=D1=8F=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5 =D0=BE =D0=BA=D0=BE= =D0=BD=D1=84=D0=B8=D0=B4=D0=B5=D0=BD=D1=86=D0=B8=D0=B0=D0=BB=D1=8C=D0=BD=D0= =BE=D1=81=D1=82=D0=B8 =D0=94=D0=B0=D0=BD=D0=BD=D0=BE=D0=B5 =D1=8D=D0=B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