From patchwork Mon Feb 6 15:48:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 13130236 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 A9BE9C636D4 for ; Mon, 6 Feb 2023 15:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230381AbjBFPtM (ORCPT ); Mon, 6 Feb 2023 10:49:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbjBFPtK (ORCPT ); Mon, 6 Feb 2023 10:49:10 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2128.outbound.protection.outlook.com [40.107.94.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 671327EE9 for ; Mon, 6 Feb 2023 07:48:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hGq3gMkG7UKNONyke16eYHC6sg1RfsOEw4XUHIZBnoNeesAt54O8FoZ+nWE1Pb/uU7GRXvryH+ygKGusjNUXwkp2URuR99rhZaUlL+BUoTfV8U2zyclEnmY/sVE1PkoaHg3HnYsCE6pCh6QJC2QFv2KZPRbjasbJvfYOR5aSPoA/Q/WlM0zgCiWY3/6gUvSdEJ9OePTmAAhEDvtdKKtUshd2DBHNRG1KO0pdKFHEpp2uLItiDmjKdr1B+iZ7kQBWMnfLlHhklyhOj26hNfZFXzLWGDYVX010YhQPS6EpaIxFX4JkqNMvfh7bQdfe1iFLrEv/iF4ZewuLX8cM9Rn2Vg== 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=sayhz05HCueU1JTdDI7m9P8J3Zi5jDktDK5SEsMH18Q=; b=nAGTFNfrw6yKSg8xPXDOXyPVDVrxR2HLqqpGMzKRFL0NhaMuOnXSx7D3JsKcbbnsIeZW7mqgTTveY5aoB7mYTW0FXkXQA5BrTQwwr9UuDMp5t7tv9O+ylBzxtPALxMLu+j/j+Y8CdL8PpJg2fXOkBp+emRl6C3JZYjwyUn/NKDY/Aa5w5muh5ZwLu55JQuxfyXB3b4KVeiUDqus4ovNASwQLcPQcimYmRcGflpQHwSdS7cUwHUZtcgg2PSdhuvi+gL1HpopcewHPXby26K/0mxBlq5Thd4tU1QpmNd4uLl3Dr8HToxfV31lBObsKa2SSUDdINZrRV6k8DDtjJ6L0aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sayhz05HCueU1JTdDI7m9P8J3Zi5jDktDK5SEsMH18Q=; b=YiaBhhjCIpx4jyUCbMuVE3H5a7oIbwW2Z56zMSj9t9465fOnhaBui9WdANGjJ1KlyK2Lgpg+77errh0P5R1U/wBrbelBtypI+4TGeSNygrcCfLjPuVrKcBg8XYZwPxhKbn/pezuq3raAZRoK3z2m2tDreWQmSEj3MnuFGmRiGbs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by DM8PR13MB5240.namprd13.prod.outlook.com (2603:10b6:8:7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Mon, 6 Feb 2023 15:48:53 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::85f5:bdb:fb9e:294c]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::85f5:bdb:fb9e:294c%3]) with mapi id 15.20.6064.034; Mon, 6 Feb 2023 15:48:53 +0000 From: Simon Horman To: David Miller , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, James Hershaw , Louis Peens , Simon Horman Subject: [PATCH net-next] nfp: flower: add check for flower VF netdevs for get/set_eeprom Date: Mon, 6 Feb 2023 16:48:36 +0100 Message-Id: <20230206154836.2803995-1-simon.horman@corigine.com> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: AM8P190CA0009.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::14) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|DM8PR13MB5240:EE_ X-MS-Office365-Filtering-Correlation-Id: 29ebe829-0c96-4546-c160-08db0859a603 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FZZL8umlDE+wjoHO5axZZypHmkH/bkmwHgM8257Ttx6OZA+mizt1Cup9oW3XwpZoElHMfx2ntLGnCGNKLrUd0QUb9c8rE5wgoegTj/N3cvuADgnmOEtfwBg4rdzujfLg4jJDHnbXgPVAsnNv5bycx3p+ZzO6lFc5k2Y0wZi1Zugj8UTOy+XUMr2ebfai3MV0ZN6hEUsXzHiezrAQfNUl/z2pFDCSGwUPi4d9fJa/9Sa+YNgJv2QKelbP8B/qasgRgD29N1BvF1Xg+nGwYmZBUzj6ps1dHdkoW6j2tFFOOWwu/E1sr/Sm5AG6JJTcKBvgPBVnfCMKYrzkTuW4sLl+QzsDpDj8+qcbMugDgzYMMGywCNQZClrXWNCu0HDo9nDBWfTMhqThVKcw7drUOjJsvFh354xoOmH1lBUQfAH16Y+scejguSExqC0HH780n5cvaogdJOwGtTZTNipxUN6ZHygpOFZD4smKjag5m49iFgzKvAYS4vZOikW1qfFf3KTswi9m8mQFjHb2ivdUQxtgAtfTJdRaaoKBHYNj+JVJWPir2gPve3GCZjmLcwOjsc+PSOQCrD907A+eW6iapgqoaBxUIqZvthBnFmnhB0VZWs5SEwZl8eXOjoYDji9070II7FeIyn7NDgydvM4g0k8wccCek4y+pggsTSku7p+VMlVJX+AaXtLhdrQgdmZj2Rgj X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(136003)(376002)(39840400004)(396003)(366004)(346002)(451199018)(54906003)(52116002)(110136005)(4326008)(66476007)(316002)(66556008)(66946007)(36756003)(38100700002)(86362001)(6512007)(186003)(2616005)(8676002)(478600001)(44832011)(2906002)(83380400001)(41300700001)(5660300002)(8936002)(1076003)(6506007)(107886003)(6666004)(6486002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7xWU0xBAs1QOSmHDwYp+YtSF3wh95Uh69e9i5WvP2v6qFPBkcyGRNNfAGY6AS/nWheYS9IZDJjKn21pMTq19UJ/3GI7xKGnyDZ1SM4o/zH5Vb/TqbmY0MJ0DVvjnkPkpTikqUavQYrf8LSpMCdtsXJ4vidzDjqY+b2a0OvH2chDMT0pJRCLcUInmXUDk7o9DSQ1vm+xfiIx8FbflGGm1QEGj9i4mVRWv2rI9OLePpySS+t7lgdX6QBS7TAWr84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er4bb08qrnlSy9E3xWnTai7QFDrc1d+ruMIXZPCsgz8xSkVKu9LlqjoeytyTZOUCL8dyYQgPpYNgXj0CnXtBE2BHDdyrtJqwjI+8gr8eCxd9O5g9/bMpM3GRsgUMLCrTgXT8AwjIj3f2YSbe+2ci/lMTW9MAgdYzz7OioHD+2qIHz3m+/cW1a1H55cQWPA9STFr81FMFH6sk1HP8o70Sxk+YSnlMGEtVLe1qrFctGJoccPsMB3UbyuzpMczdBsvi+77KIq7SbSb/xLWeOHLf+RgPz3c1sVtR2UD4lbmeXpoOKJC0yg7yduaQHyq9vsoNYzVQDLvafXKPH5lnVTBxYzffhj7LDlvsQ== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29ebe829-0c96-4546-c160-08db0859a603 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 15:48:53.5944 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dnZ8GK3A6KiQGLyCTnY7Av4YSMD8jYRib8Vs+KFIDCVM7tyP3IvkwYFwskPFawEDZlHFGvig1rqbzo+iO07NH7Ia7etp4dMVy7/1522/hLE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR13MB5240 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: James Hershaw Move the nfp_net_get_port_mac_by_hwinfo() check to ahead in the get/set_eeprom() functions to in order to check for a VF netdev, which this function does not support. It is debatable if this is a fix or an enhancement, and we have chosen to go for the latter. It does address a problem introduced by commit 74b4f1739d4e ("nfp: flower: change get/set_eeprom logic and enable for flower reps"). However, the ethtool->len == 0 check avoids the problem manifesting as a run-time bug (NULL pointer dereference of app). Signed-off-by: James Hershaw Reviewed-by: Louis Peens Signed-off-by: Simon Horman Reviewed-by: Leon Romanovsky --- drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c index e9d228d7a95d..807b86667bca 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c @@ -1908,12 +1908,12 @@ nfp_net_get_eeprom(struct net_device *netdev, struct nfp_app *app = nfp_app_from_netdev(netdev); u8 buf[NFP_EEPROM_LEN] = {}; - if (eeprom->len == 0) - return -EINVAL; - if (nfp_net_get_port_mac_by_hwinfo(netdev, buf)) return -EOPNOTSUPP; + if (eeprom->len == 0) + return -EINVAL; + eeprom->magic = app->pdev->vendor | (app->pdev->device << 16); memcpy(bytes, buf + eeprom->offset, eeprom->len); @@ -1927,15 +1927,15 @@ nfp_net_set_eeprom(struct net_device *netdev, struct nfp_app *app = nfp_app_from_netdev(netdev); u8 buf[NFP_EEPROM_LEN] = {}; + if (nfp_net_get_port_mac_by_hwinfo(netdev, buf)) + return -EOPNOTSUPP; + if (eeprom->len == 0) return -EINVAL; if (eeprom->magic != (app->pdev->vendor | app->pdev->device << 16)) return -EINVAL; - if (nfp_net_get_port_mac_by_hwinfo(netdev, buf)) - return -EOPNOTSUPP; - memcpy(buf + eeprom->offset, bytes, eeprom->len); if (nfp_net_set_port_mac_by_hwinfo(netdev, buf)) return -EOPNOTSUPP;