From patchwork Tue Nov 15 15:10:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Changzhong X-Patchwork-Id: 20421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2773820wru; Tue, 15 Nov 2022 06:57:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf6hSUclRocsE7VoK4udmoG6y2FKuisjkspEpCpAgVuaksVtpeoHJgsmCsvALsF9SXnqMu2E X-Received: by 2002:a63:4e53:0:b0:473:f7fb:d2c7 with SMTP id o19-20020a634e53000000b00473f7fbd2c7mr16298063pgl.535.1668524237115; Tue, 15 Nov 2022 06:57:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668524237; cv=none; d=google.com; s=arc-20160816; b=vI1Eb5kklX2WcohCT6svwcgEDcTSPt0rdLG6CLZVW/MkBnEUcNCpelt4Tfbc+QLAeb MdUhP6z+4owTC7GNCO//I+Z4L1RQPxOJnUU+ZO7WOfVJ8Y1T9rBwZ3AxJT1Bjp5Bl0kX l1tFkFOnii9qs7iU2lD37673FdZzwsR5Zl4htd5rLmkoBz1HPfEk3aVkS7/jAnnzl4jK uiZCOwYfjwX/qNjmr7/LiAFxZuA3IxJ/mTP+hWLW/Vpe7yQzXbRrBAUoZUL3aesupJDm vWawwLmqSuy7oNNxwwsi6VMp9T/idVivDHunjh4WPPKmMbRGVw61LBEz2JKeWXJ1gb4w L+8w== 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=EU/3fhXW9ARUActm+PaU1dLMivs9vjSktz7zVje4WCM=; b=RkKgkhp+A8hl4yEDk5GROna34ybYYJjKpTzDEyqhqLHVo1HTQ2+N2QqOwOu34dmN5I /Grn4jzKS32AeRpOpkKXikGGwocAP2jl6IdE+opNS7+XnBOW7um7KSfcffHnnqmGjmtL GbdGMiRJSFafmZ4tcOEGxNkSNYBHmGMJldl4HgPdPBIBsXD23MC0CgaTY1ULit01RhAv RLhe0TG52jsNNpmZGYRmgAe71FZ9/nKeru8DeEnJThwytQ8j/OyANuYqQd4c3lu1MzMC X+ZUBpHgtGMu3m0IkOWiOGolxU3XzbEQZ1lDHNcyvzNfJgjUzbRsEoEk21nhufUECuAW ze5Q== 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 i1-20020a6551c1000000b0047030c28b16si13308583pgq.184.2022.11.15.06.57.03; Tue, 15 Nov 2022 06:57:17 -0800 (PST) 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 S230177AbiKOOvk (ORCPT + 99 others); Tue, 15 Nov 2022 09:51:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbiKOOv2 (ORCPT ); Tue, 15 Nov 2022 09:51:28 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48C6124BE9; Tue, 15 Nov 2022 06:51:27 -0800 (PST) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NBTd93QlTzHvsR; Tue, 15 Nov 2022 22:50:53 +0800 (CST) Received: from dggpeml500006.china.huawei.com (7.185.36.76) by dggpeml500026.china.huawei.com (7.185.36.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 15 Nov 2022 22:51:23 +0800 Received: from localhost.localdomain (10.175.112.70) by dggpeml500006.china.huawei.com (7.185.36.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 15 Nov 2022 22:51:22 +0800 From: Zhang Changzhong To: , , , , , CC: , , Subject: [PATCH net v2 2/3] net: nixge: avoid overwriting buffer descriptor Date: Tue, 15 Nov 2022 23:10:23 +0800 Message-ID: <1668525024-38409-3-git-send-email-zhangchangzhong@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1668525024-38409-1-git-send-email-zhangchangzhong@huawei.com> References: <1668525024-38409-1-git-send-email-zhangchangzhong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500006.china.huawei.com (7.185.36.76) 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?1749574470280514511?= X-GMAIL-MSGID: =?utf-8?q?1749574470280514511?= The check on the number of available BDs is incorrect because BDs are required not only for frags but also for skb. This may result in overwriting BD that is still in use. Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev") Signed-off-by: Zhang Changzhong Reviewed-by: Francois Romieu --- drivers/net/ethernet/ni/nixge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c index d8cd520..91b7ebc 100644 --- a/drivers/net/ethernet/ni/nixge.c +++ b/drivers/net/ethernet/ni/nixge.c @@ -518,7 +518,7 @@ static netdev_tx_t nixge_start_xmit(struct sk_buff *skb, cur_p = &priv->tx_bd_v[priv->tx_bd_tail]; tx_skb = &priv->tx_skb[priv->tx_bd_tail]; - if (nixge_check_tx_bd_space(priv, num_frag)) { + if (nixge_check_tx_bd_space(priv, num_frag + 1)) { if (!netif_queue_stopped(ndev)) netif_stop_queue(ndev); return NETDEV_TX_OK;