From patchwork Wed Sep 25 13:51:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: George Rurikov X-Patchwork-Id: 13812029 X-Patchwork-Delegate: kuba@kernel.org 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SPB-EX1.Securitycode.ru (172.16.24.91) To MSK-EX2.Securitycode.ru (172.17.8.92) X-Patchwork-Delegate: kuba@kernel.org 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(-) -- 2.34.1 Заявление о конфиденциальности Данное электронное письмо и любые приложения к нему являются конфиденциальными и предназначены исключительно для адресата. Если Вы не являетесь адресатом данного письма, пожалуйста, уведомите немедленно отправителя, не раскрывайте содержание другим лицам, не используйте его в каких-либо целях, не храните и не копируйте информацию любым способом. diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/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 = max(ec->rx_coalesce_usecs, ec->tx_coalesce_usecs); scale = rtl_coalesce_choose_scale(tp, coal_usec_max, &cp01); - if (scale < 0) + if (scale <= 0) return scale; /* Accept max_frames=1 we returned in rtl_get_coalesce. Accept it