From patchwork Fri Apr 21 17:06:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 13220444 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0628DC7618E for ; Fri, 21 Apr 2023 17:08:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232895AbjDURIV (ORCPT ); Fri, 21 Apr 2023 13:08:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbjDURIT (ORCPT ); Fri, 21 Apr 2023 13:08:19 -0400 Received: from DM6FTOPR00CU001.outbound.protection.outlook.com (mail-cusazon11020020.outbound.protection.outlook.com [52.101.61.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AA4D14F73; Fri, 21 Apr 2023 10:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WOZIAsabLeElelHpYnRgGESRg03v3VZeYf3/HhWFnWmrmK7+ljwzjjJYf4+keX/Xv+Gg9XTDqNYoDFVMNvAVO/fd6xvVUD5l1BzqmWJTH4pd3o1ZPgooQF1Yux6rBYuft/miK8eQClxRIow3VcRtUQleqWnJaYaQyGOGoYkiwhtoISezkzj/3WeVTHQnWF52QEaonFfC25xdZBxp4lrZjEtelmaGKk3EEGM9QzeUcyxxlMsdwZbVliLLYXp86obeDxNJ3FjRuPe2F0/vCAoE9JeBXYzf/HWTFxHyscBZ6IoEKTHzt85V9ANpH5u/zg7/IOBXw2OQcvSIxhy6Z4CVOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HokZVZmB0QLjZGEZYrBqXZ1bRmR73URn6MkLEm6ke4o=; b=YVFnH/qTI1S9NVRVHdvx5V4dwFvnoLIiNu77AA7QfS8woSEeYAh+XxYhV2FCqJgqR7d+EZb/tBK5p2TxvxZge/exjdoBZ5jywrE5Szy5ExOJMeO50doN6LbX3F+8RhCT13BPbg43JljkavxvuruA3KXLFfu+V6lgeJh8UPmJMdZ03JlqBRLAcBf/oVCCNTVZLSpu/acS/Hg97H1IYJBentIYF0e8Tv5xSPvD+MBuf04GCor8IRhab8AZ32pE+/CXnOvUlpxVUc+eL0I4Q2GDYbAOoU0fU/26iUTyagEArgUetHl6Mes9XArl5SmBxqd3Li/rimy+BHM8ZJylr34GrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HokZVZmB0QLjZGEZYrBqXZ1bRmR73URn6MkLEm6ke4o=; b=Pt9kNOiC94ZZ+vxYdqI0mO5Qky75xFRJ+H+odQ2MaD+bgHCNmoEqlrswEJ6zyc8y1M8QqkbivHzwrowhm6J+3wNsr9MZn5arjtC0J6/p2rNASbeI72aBwytXGjwBw2fmwFicnXN8rZaO/lXb+ZHAsruu9fxpjFtfgmYQ23qMmAc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) by CO1PR21MB1316.namprd21.prod.outlook.com (2603:10b6:303:153::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.11; Fri, 21 Apr 2023 17:07:58 +0000 Received: from BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::3e5b:6d93:ceab:b4c6]) by BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::3e5b:6d93:ceab:b4c6%4]) with mapi id 15.20.6340.015; Fri, 21 Apr 2023 17:07:58 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, kys@microsoft.com, paulros@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, wei.liu@kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, leon@kernel.org, longli@microsoft.com, ssengar@linux.microsoft.com, linux-rdma@vger.kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, bpf@vger.kernel.org, ast@kernel.org, sharmaajay@microsoft.com, hawk@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next, 1/2] net: mana: Rename mana_refill_rxoob and remove some empty lines Date: Fri, 21 Apr 2023 10:06:57 -0700 Message-Id: <1682096818-30056-2-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682096818-30056-1-git-send-email-haiyangz@microsoft.com> References: <1682096818-30056-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: MW4PR03CA0102.namprd03.prod.outlook.com (2603:10b6:303:b7::17) To BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR21MB1443:EE_|CO1PR21MB1316:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d02f1d2-561f-4faf-765d-08db428af4b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8RGcsWHecvjNNsDIEUVzMT6w2ShNZVVRyltjc54KXTXa83NJb88RRcXlCTqWqRRGSzrAqow6WbU/Qvrp5KpYpoBbiDhClb8BwCjRssFyAzrQKGKybC6nc3tqgIZbubZnT4dUQGgAz70mohkxqWDZTmL/XcqNi9ZxWyHXjnDnCcS/zzcYZIzhcHzkm+YodlURr/+vGvrRH0Q3bCuguj+uobrSJlQbHHsrVbj41K2SFSk45Loi1h4MA3mhhsdlvfYY9d0fTD6PmbsaoFLX7SUTFNkujZ0X1GYlEHDkqK1q/80pLsrb/frO2px6GBebNUaqP3m1Kl2WsQMwmZfc65mMWNLVTBMSf3ZSL8s1fw2IZlyQ2WtD3ndhC7yP9btzDnWqFx1xf42K6WzTiu9qd8U170nkXjxWSmC3/mLtu3Z5HJ5FpkJyBh8g2fXXbiREaESJbiryiNEjmlIxWJNfZM2XjAw7EG7mhuzoMrqri1pu3CgyW+aHcCpdj1aS3lf7MP/R+GnlikslARCy3tZztlV4GUWJfaCj0PmG6t958sQSjyb9QUumd5esx4rX6xaXStazy5B/9SKlPeRUJk+doca8ZuRuLgk+nwZZdol/oY9ZShS4t/DZNcQZtB96Je653ztwZTCp1eJwksThYkkj7nlazre/2VT2/SRtIGNaoXwtnN0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR21MB1443.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(136003)(346002)(366004)(39860400002)(451199021)(4326008)(66946007)(7846003)(66556008)(786003)(66476007)(316002)(36756003)(6506007)(26005)(82960400001)(38350700002)(38100700002)(82950400001)(6512007)(2616005)(186003)(83380400001)(5660300002)(41300700001)(8676002)(8936002)(478600001)(52116002)(10290500003)(6486002)(7416002)(2906002);DIR:OUT;SFP:1102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tTjbuQv7iKlDfj8TaNQLSYzyBRo11fderu1EZO2dWxd3NLwJ3g2pUmsporvZA3NogqwjwVQZqo44YWGUkqWWOEvK0R01fpuublo+Yb9+2WuOO6XppGhx4bZhqAwFKI/S0fhGTdM4rsunKlWWsk30bBgxDObv/8yghioaIC6CvpEBnqH8f5jWNqD8O9BcnkrUHQXUAHhytdTGrnkysGnfgWVZdkx+zJokegybtYFd5GbLa2gP3U0wJPZ5oSDOrPqMSB3tiN06bX8t9JvwE6SGfQSa9iR6BcfNKmTV3xkFA+s0dbWiMuA7iDBu3nfB8JLsE+V7Ul4YFqRbr76pcBqEGzE0Er4DNTLnZ+pvbBFC/rEBIR1Pt5jtrNKsBoFxZajhT4uwBGN7AeMmmha2FT62CcqTWiiSt4EE4jIp36c8kHbc3AVVkHDHi5lhjM8Gq1qppVBadWAf3B2aVCTOFIDYYdKnKq1Vj7XuvhZtcV5K8cVK70YJi1OoFlBvDzEJOnCWome7wHzb5mMC5/UgUvh8FjuqAABmS50ZdP0V/RFipGxjifGWP7E+YtY5hm6989FmGBGIX1hT0l3pTf X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d02f1d2-561f-4faf-765d-08db428af4b3 X-MS-Exchange-CrossTenant-AuthSource: BY5PR21MB1443.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2023 17:07:58.2586 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 30LjWCM/a9AnyTtW7KW+KdV/RT9rK8o5CaavhyrhWdAi2ujXdzZBv3uoL5B1YBIHPKtuCFGJVGeX0TpyZToj7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR21MB1316 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Rename mana_refill_rxoob for naming consistency. And remove some empty lines between function call and error checking. Signed-off-by: Haiyang Zhang --- drivers/net/ethernet/microsoft/mana/mana_en.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index cabecbfa1102..db2887e25714 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -563,7 +563,6 @@ static int mana_pre_alloc_rxbufs(struct mana_port_context *mpc, int new_mtu) da = dma_map_single(dev, va + mpc->rxbpre_headroom, mpc->rxbpre_datasize, DMA_FROM_DEVICE); - if (dma_mapping_error(dev, da)) { put_page(virt_to_head_page(va)); goto error; @@ -1515,7 +1514,6 @@ static void *mana_get_rxfrag(struct mana_rxq *rxq, struct device *dev, *da = dma_map_single(dev, va + rxq->headroom, rxq->datasize, DMA_FROM_DEVICE); - if (dma_mapping_error(dev, *da)) { put_page(virt_to_head_page(va)); return NULL; @@ -1525,14 +1523,13 @@ static void *mana_get_rxfrag(struct mana_rxq *rxq, struct device *dev, } /* Allocate frag for rx buffer, and save the old buf */ -static void mana_refill_rxoob(struct device *dev, struct mana_rxq *rxq, - struct mana_recv_buf_oob *rxoob, void **old_buf) +static void mana_refill_rx_oob(struct device *dev, struct mana_rxq *rxq, + struct mana_recv_buf_oob *rxoob, void **old_buf) { dma_addr_t da; void *va; va = mana_get_rxfrag(rxq, dev, &da, true); - if (!va) return; @@ -1597,7 +1594,7 @@ static void mana_process_rx_cqe(struct mana_rxq *rxq, struct mana_cq *cq, rxbuf_oob = &rxq->rx_oobs[curr]; WARN_ON_ONCE(rxbuf_oob->wqe_inf.wqe_size_in_bu != 1); - mana_refill_rxoob(dev, rxq, rxbuf_oob, &old_buf); + mana_refill_rx_oob(dev, rxq, rxbuf_oob, &old_buf); /* Unsuccessful refill will have old_buf == NULL. * In this case, mana_rx_skb() will drop the packet. From patchwork Fri Apr 21 17:06:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 13220445 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 918C7C77B61 for ; Fri, 21 Apr 2023 17:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233224AbjDURIq (ORCPT ); Fri, 21 Apr 2023 13:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231936AbjDURIp (ORCPT ); Fri, 21 Apr 2023 13:08:45 -0400 Received: from DM6FTOPR00CU001.outbound.protection.outlook.com (mail-cusazon11020020.outbound.protection.outlook.com [52.101.61.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A67652D56; Fri, 21 Apr 2023 10:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lvH3/riMhqTqmpeSKabzGExQw/rkSfJcl7yNDYrx0DwcHtqjqD6POsx8HdkXYHucYN0SndRroKqLa2wH2w9w3vQTKaAjrnGd0f+zurO/vnyTM/gKvaGWlz8x7aMkBfXcp0grrbxyvWyj3PWYoeO2ZVe7bB9XQwJs+9F01fzQA4qmVbdnBa+w5dj9I++s5AGVErMJj80KzFB8B3k+D5XQkLKiZ/mcR4VwTzo9S1Mcyi085OatZapaAk3OjmQX0BWGDT/gR2xSZArmPj25wGMjVfd23Xtv2opqcZtN3jsakI9nzEe60mMLEhL/LREexdhMoeLQev/lP5XeyDsRQ+75kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k1HmhJxV6cmUgswVaDI/a//1gqwtqv777RmGSU5xq7I=; b=MfDWTYDEMgx+2m/+gX+Lcc4uwsduwlAjBO2Y+e5bqc41XGpLob4ui3kjXsYk7qad/UdZKvYkr985R9XGIjM+hQos9507boWqj1N4X3vfHT2vjr2VRtSqkRcPsoNmrULKMvXDb637/Z9ho7tWMLMC3Gy93Uw5DY4Fu9wzPpZXDCoriPea3oQT3RPPwevak84/gXziR75JqTbLpG3y8dA5wtM3HTuCZgnjg6S04/A15cP1omWQAqVt1KheNAnjcv9WJVDzMwmhZ2Kpo6428gjBxG1iFxgjC+O7Pq7PbaDBsHCDxOkqbD9eST2Bf3ls1LXX5arV/BhCCz8FJ5mcK3+m/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k1HmhJxV6cmUgswVaDI/a//1gqwtqv777RmGSU5xq7I=; b=SREZIXHHMM8LuERNkIXC28+cP3oRLsNs+jKUZ5e0eLbEW+gpl8hsi8qAAzZyYlSM5GnR++/4mCnn2bjyAZMe4ljZoiMuyNYTMv28I6BjeIW6KLClRv0jJpe/AL6bragv4X1x6wr6AQtUz3If2OGX2vOm18JE0DHA5nzvOABGfrM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) by CO1PR21MB1316.namprd21.prod.outlook.com (2603:10b6:303:153::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.11; Fri, 21 Apr 2023 17:08:02 +0000 Received: from BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::3e5b:6d93:ceab:b4c6]) by BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::3e5b:6d93:ceab:b4c6%4]) with mapi id 15.20.6340.015; Fri, 21 Apr 2023 17:08:02 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, kys@microsoft.com, paulros@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, wei.liu@kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, leon@kernel.org, longli@microsoft.com, ssengar@linux.microsoft.com, linux-rdma@vger.kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, bpf@vger.kernel.org, ast@kernel.org, sharmaajay@microsoft.com, hawk@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next, 2/2] net: mana: Check if netdev/napi_alloc_frag returns single page Date: Fri, 21 Apr 2023 10:06:58 -0700 Message-Id: <1682096818-30056-3-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682096818-30056-1-git-send-email-haiyangz@microsoft.com> References: <1682096818-30056-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: MW4PR03CA0102.namprd03.prod.outlook.com (2603:10b6:303:b7::17) To BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR21MB1443:EE_|CO1PR21MB1316:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a78a2f4-ef35-4113-78c7-08db428af71a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wba/7GADcIhlqE372dLxFMN2Ro2+btQwLEUSRjv4tZACp5rhgjQ23Yrk3zVREnVw8i2ssoKY7mivMJLYPTQgWeeB0jiKuQRBrA9BW/zt/Q3wiiDMeTFt5xT3jnCubC+lI4jPdJIBVR24wz1tBsFfeRvAQeZDdLe5Iy9J/ElyE+y9lgTB4ZkwE7AvGJv2HpkyYO4dV8dhFzpw5kq6Bl40R2WoNaZuWOTCOt4dvdRIYoIqhhg+j1aVdGbVigawF1zJC/GGZ1lOrdW6yyeX/uHf3Mc+EgvLwCPNNjDua287612XHECZR1DhKHh9wZHfLBUa83nxfcR/RCwjn9VkEv+aRegeopXVd6evIMqgo+gHSsQzn0NFxA5ZBkaOWujqfWZGdXG1D2696eLHL9IjVcUnptJC+L/TBQ55Qty70IDLxAQ5oAWFH62MvSD2gPY2on4+3FadWG7eQVmNCbWkv0VsOYYqxxzzHPAtskZHbLD8agbl9PxJSmFE8hCov6g4jBE6ucoOjmeYwsh2BLJSnEUQzFR2hk2fhW4WRDMVBo7b4fWRIX7Ek8nlsBdiZnRzqQvVBGcyj6OtqBpPGKWa0xCFs97NJtmrj1TXhTfSVebVXDNc30EdRyChMzcfWBQf/I/KSjsCAqkXCv08v9YEJoOjoF8SguU9HaLFJsMNzqV/IDk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR21MB1443.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(136003)(346002)(366004)(39860400002)(451199021)(4326008)(66946007)(7846003)(66556008)(786003)(66476007)(316002)(36756003)(6506007)(26005)(82960400001)(38350700002)(38100700002)(82950400001)(6512007)(2616005)(186003)(83380400001)(5660300002)(41300700001)(8676002)(8936002)(478600001)(52116002)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pwK6e7YiXAI7MwWuJboZC8gvGXFytbeDuexvqC3YFyJo3f5GzTase0r8Swu07tr5O1bY1Vcm/RzN8JQ+arDHT7SxIjfrsjf/EixIx5tD2YwqiOuiuxGBZ3x0W9ofp6rXLs6Tgw3FnIO624hDCVQTQYYgViUudcCLVS4inMo8yLSDlT7HQiczWzRwmPdxeeiYg/WdgWzKtsvr6a97g4JKsvf0sxiq7eUud9j209AKC0JIGWkUWt4RZ4rcdBwqqEFEUyJgTBLZEvLaHia6/vCLgqJcQh6YQqPsMyI8xYwOsC77EcE9qPwmC4htEST5BGQs6GaPSTRSTMQxF6JKYjrWRx/EYTkI9JWoPKEZ4wRN15mS9oGARnzhaVtTxzkUa3tSikOrLhjxY6xa1Tv1awKzjk6uT1kzSn85Nt3NjDcgAeuDMTtBrz5LQzVeujinZUO/YDlY7AwRoXx9mT8J/pZL/KdgNoYKF71bGviCoG44QVtTbhv/SfHvK1Px4ih3qbwqgJELqKvVUbbgomozquyZYaqsuh/9egvHXuZgcKjPXHofHSK2n1vI2H5ARC/6syqSYiAJByhbEa16bFZWtGAt18O1P6ze9DgrkYXXrM3nQl+h7fSx49WSsD X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a78a2f4-ef35-4113-78c7-08db428af71a X-MS-Exchange-CrossTenant-AuthSource: BY5PR21MB1443.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2023 17:08:02.2854 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0V3mpMbzuAt4yHlJy7q8xx4Ro+przExRNcllL+IsMVGqAVfOb43c9vkbeF2UjrEKuWHKVoY7Iqze/71OYjGTrg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR21MB1316 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org netdev/napi_alloc_frag() may fall back to single page which is smaller than the requested size. Add error checking to avoid memory overwritten. Signed-off-by: Haiyang Zhang --- drivers/net/ethernet/microsoft/mana/mana_en.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index db2887e25714..06d6292e09b3 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -553,6 +553,14 @@ static int mana_pre_alloc_rxbufs(struct mana_port_context *mpc, int new_mtu) va = netdev_alloc_frag(mpc->rxbpre_alloc_size); if (!va) goto error; + + page = virt_to_head_page(va); + /* Check if the frag falls back to single page */ + if (compound_order(page) < + get_order(mpc->rxbpre_alloc_size)) { + put_page(page); + goto error; + } } else { page = dev_alloc_page(); if (!page) @@ -1504,6 +1512,13 @@ static void *mana_get_rxfrag(struct mana_rxq *rxq, struct device *dev, if (!va) return NULL; + + page = virt_to_head_page(va); + /* Check if the frag falls back to single page */ + if (compound_order(page) < get_order(rxq->alloc_size)) { + put_page(page); + return NULL; + } } else { page = dev_alloc_page(); if (!page)