From patchwork Sat Nov 5 08:07:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yue Haibing X-Patchwork-Id: 15924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp876536wru; Sat, 5 Nov 2022 01:28:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5kWZzPOXWKZ728uhzj4UfzMDjc7uqsdz0nHWshyUCeQ4N5EV2GtqgcafWVAP9UH2VmLclK X-Received: by 2002:a17:906:9c83:b0:779:c14c:55e4 with SMTP id fj3-20020a1709069c8300b00779c14c55e4mr37726687ejc.619.1667636927922; Sat, 05 Nov 2022 01:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667636927; cv=none; d=google.com; s=arc-20160816; b=njxw4CoPeQxg1hKcqLGJaHow1xLu1TpOVAU2iKfLd487/w3g6Jw/rnlCX4rLnIXFjC 3kl/j21jzptiAX9TJJcMOwdvwTHGWu1fOzCXZ8lQtqzyV2h825fcIuHOjDN84ek/stDK LpfgLhmqVNRbkARJ2f2HSc33/53/ouh6dVi/XhnH0aYTn88rBRIrSelcJt1Y0WMc2kzO V0ccLXwMNmwFgp8pZqGncJNinwLUOuFbsjraN9E1+nIfegwO4yTwOf+k4lnEJG03ZMk3 l9mAM2r556TTM8nYp8knsWWZV0OBYDer0rpnjjg7EfAMWhtm/IiRrFKIHqooj1avgVHp 8PHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=9XgUuvwCAcGplwRdnRF+QhGNqPp/YzwJI9ZDuwMMNRs=; b=Q78UFJvdNih0M5HqXZiUrZLpzahpAx23qqiDRlpHEjSe9dKTZe1qPl9GONtKwjqE4G qCQBnXlIyKaBtVTB8vAxdDoUqYWTWFvFuMO/ehV8MEAQPIoueBxKstXKknu8M/dsgjw5 lvmpzA1oB0GSPVpdNAP1LpodQBtNi2GUfsJdhrOy/kc2sUFMpDQiLPmotCAUf3mi51nM eSuhoHtcqBiVE/qF5qA6weXSFu83ncTB6n0OHqcLZEDuka1+m0ErMAiiZUwFWgDcKVMk +6OtqypSOZGGLxyLWiN5du5FPUewqassl7KmbDUq8gD2DMxcRqfrdaBFb4akwCfcoGXk c14Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc5-20020a1709078a0500b00783d1a13d69si1917853ejc.231.2022.11.05.01.28.24; Sat, 05 Nov 2022 01:28:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229626AbiKEIHz (ORCPT + 99 others); Sat, 5 Nov 2022 04:07:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbiKEIHv (ORCPT ); Sat, 5 Nov 2022 04:07:51 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79A752B181; Sat, 5 Nov 2022 01:07:48 -0700 (PDT) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N495G0VylzJn2H; Sat, 5 Nov 2022 16:04:50 +0800 (CST) Received: from localhost (10.174.179.215) by canpemm500007.china.huawei.com (7.192.104.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 5 Nov 2022 16:07:46 +0800 From: YueHaibing To: , , , , , CC: , , YueHaibing Subject: [PATCH net-next 2/2] net: txgbe: Fix unsigned comparison to zero in txgbe_calc_eeprom_checksum() Date: Sat, 5 Nov 2022 16:07:22 +0800 Message-ID: <20221105080722.20292-3-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 In-Reply-To: <20221105080722.20292-1-yuehaibing@huawei.com> References: <20221105080722.20292-1-yuehaibing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500007.china.huawei.com (7.192.104.62) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748644059046631398?= X-GMAIL-MSGID: =?utf-8?q?1748644059046631398?= The error checks on checksum for a negative error return always fails because it is unsigned and can never be negative. Fixes: 049fe5365324 ("net: txgbe: Add operations to interact with firmware") Signed-off-by: YueHaibing --- drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c index 9cf5fe33118e..167f7ff73192 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c @@ -200,10 +200,11 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) if (eeprom_ptrs) kvfree(eeprom_ptrs); - *checksum = TXGBE_EEPROM_SUM - *checksum; - if (*checksum < 0) + if (*checksum > TXGBE_EEPROM_SUM) return -EINVAL; + *checksum = TXGBE_EEPROM_SUM - *checksum; + return 0; }