From patchwork Thu Oct 7 22:45:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 12543705 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85F35C433FE for ; Thu, 7 Oct 2021 22:46:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61E8061263 for ; Thu, 7 Oct 2021 22:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233976AbhJGWsh (ORCPT ); Thu, 7 Oct 2021 18:48:37 -0400 Received: from mail-bn8nam12on2104.outbound.protection.outlook.com ([40.107.237.104]:13057 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229778AbhJGWsg (ORCPT ); Thu, 7 Oct 2021 18:48:36 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V83g6CWJ5kMNgjrZvDq/i6bq9oenniaKYGEafxFQPudeOeBbFjmnmdI59jh5vlBBcNijVT0mgY15CiSih9KJkVE95Hvz5g+1NsNO5puCwLCWoVSXa5yAPY/8YcX4k1+modj0unqEDYYeywWULREXA1lw9thhdrErQOL1za9ol8/p7XLOg1AeY4Jdlazzi3KuxYjDuRYr69pIuFSuYGBYDoRUR30AAtLb9HhDO9mCiQI1DVUFBqc8XRvNRZU3RUvUxAi1ZQyBU7CbmmUaaC/FKrF8L7J/Jk+38PYesoox2BHn/i+7rMPF8hxlr35RACNgG7jQUnr1mpSlMNrbIdiKeA== 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=qdhhv2v0QWkxbFdGGhFQgSGkJA/ZlZDhBRrXOK8z6f4=; b=eJeYSE2UGro5OJqt3ZclhHngQQBIHGr8V/l24JoQx+UE6GeI3OTzaIbJULRte3K6TzGQ3yJxR/4y1uaZRKsIY7Fdt8eo052+BABj0wO7SjozA58uciQw2sjaUUxZkmVn7JqaEFdbz0339ackAhBP+Zczt5OU79A38xphkKyOIJzvIy1wgwybe+Pon3PsqFWvFn3CL3GPldJ5vTM+NjzuE25PZ5LwKQQiJu5UCr4zjZjca1e6q46zXCmuRecHq6meIHaZJ3aESCjCORrkJhRicmCrMNQjLhaB4s5OUuesbSX1j7p3/yA2Kpx2HOD97KnbSmp/F+3D4ZJ0XiihvQvpEQ== 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=qdhhv2v0QWkxbFdGGhFQgSGkJA/ZlZDhBRrXOK8z6f4=; b=BwB8/fLSlQa70rKOxK11ZKweGtV8PEAEQfhWIi+LAWmyIT3ZMdqedK8WenjJihjafbdFhd5voZUQQcTe6+KTpuQZH5B0imhLlp2U9uDzt59esJvCS/5P0+pUIplc//ML9pYLmfir/ZyuClLjEXoBi97Vv0mlbIl4FT+fFKOsZfw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1340.namprd21.prod.outlook.com (2603:10b6:5:175::19) by DM5PR2101MB0805.namprd21.prod.outlook.com (2603:10b6:4:76::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.2; Thu, 7 Oct 2021 22:46:39 +0000 Received: from DM6PR21MB1340.namprd21.prod.outlook.com ([fe80::10b6:1733:cf27:f6aa]) by DM6PR21MB1340.namprd21.prod.outlook.com ([fe80::10b6:1733:cf27:f6aa%6]) with mapi id 15.20.4608.005; Thu, 7 Oct 2021 22:46:39 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, kys@microsoft.com, sthemmin@microsoft.com, paulros@microsoft.com, shacharr@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, linux-kernel@vger.kernel.org Subject: [PATCH net] net: mana: Fix error handling in mana_create_rxq() Date: Thu, 7 Oct 2021 15:45:33 -0700 Message-Id: <1633646733-32720-1-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 X-ClientProxiedBy: MWHPR17CA0070.namprd17.prod.outlook.com (2603:10b6:300:93::32) To DM6PR21MB1340.namprd21.prod.outlook.com (2603:10b6:5:175::19) MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (13.77.154.182) by MWHPR17CA0070.namprd17.prod.outlook.com (2603:10b6:300:93::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Thu, 7 Oct 2021 22:46:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8f65879e-96ca-49a5-dada-08d989e45297 X-MS-TrafficTypeDiagnostic: DM5PR2101MB0805: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1060; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IdHhTnMyQDN+0XWRwSsEsAtQyaqMdZ9/ghu2SDdlFWzKli0eKIKc0BuayNu+OhsP0A4O5kegQuGlI9dJzu4RjmZYHi8tm0QYErNDj4s2ycMavidAgAM/FVOeU9chY/hWefckcMFTlV4mUOLMLXJHBMnxsSHZMlSigZlor4DEldPR4pNWn/4nzl18n3isLMikDnXHdVv1r30I1PZY5iF5l3D2ZB19qoMyF0meja+EHfMqj3HmM3yP24McTqjNbll7huPk+XUQxqlBeWFM3opwxr4t0ePuaJldCU3B5Xz/1Ti1VsItm3hsCmmWHVd8HboSrGaIdFTu92035ngdOEDsRozqIdleWOZ5yGKB+lzz9skcqWhowHsFUYfoEOpTUR+T4MsqcI5D1f2KPpluWA09Vle+f5cRTI3OsETAd1qFRAxbNAXpJxtevgFEMcwZtiM16h5yo2+E4GRPMEpe/D9Yb/I8kFPdPc7RgLt5VUyojiA6wxkEO/8g0MCLtzhpmaDj1x1FctGermHP0OpC561hgEB/Z/XA+mTGVd7JqJG8fOjH+Zto2tBQuvgKFNBbP01ks5bPrWnpDxM6S8WLIpJ5E9s4+yO3IldozNL+gCBOF2bxaIMh05o1ZteICvaLN7pcEHJSgEGGB37E6YeD4FlYSHZjKaPB/YgWBHLVFfnjvn5rGCNcS1mKFMkvOYWzU1NZNe3wGzQCf3YT28bEfFOzFQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1340.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(66556008)(66476007)(2906002)(66946007)(10290500003)(5660300002)(316002)(83380400001)(6512007)(6666004)(4744005)(508600001)(52116002)(38350700002)(38100700002)(82950400001)(82960400001)(2616005)(4326008)(956004)(8936002)(6486002)(6506007)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SMRlcw9lNloecLbVSj0Xna3jgOnEMSoaP9o69vawlpWZl1M89/5iHXkC0cUnCp4ZWE1R5dzCOCg6ZdWf/klACO+gFyY2J/KdkQcUcax9YoxythnHatGFSohX8kKqNlvIsnkFzEUookdeo/is7PTLDYFv3/8NuXPplEqOWYFdrWzl4yfHDUZP1omKHgMrpSi+HxgFYPmPQMremyKoFVNXP3Hx1+DcIo7w9KHdOthTqvfAHvtMNd0hBqzV4T80nchsYJTVkA1gkm1ubtGOAgRA46nq+PGzX0ydj700dGCMPFl3AxS5r/lG7D6uQv241HIUwufv7Kx8SEbMnT8umzTsU6kuTF+tD+GzS5oN2lgfBFCCRv7 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f65879e-96ca-49a5-dada-08d989e45297 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1340.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2021 22:46:38.9380 (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: JX0nUG1X6XrXe9wvy5gHDPdHSzJEYsWi0yXIk/gML23skdgOXA3XwdWUArWngXg0srhHVTnL78x7Z9daNdiLCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0805 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Fix error handling in mana_create_rxq() when cq->gdma_id >= gc->max_num_cqs. Signed-off-by: Haiyang Zhang --- drivers/net/ethernet/microsoft/mana/mana_en.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 9a871192ca96..d65697c239c8 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -1477,8 +1477,10 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc, if (err) goto out; - if (cq->gdma_id >= gc->max_num_cqs) + if (WARN_ON(cq->gdma_id >= gc->max_num_cqs)) { + err = -EINVAL; goto out; + } gc->cq_table[cq->gdma_id] = cq->gdma_cq;