From patchwork Mon Oct 24 12:33:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 118988 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A64A1A034C; Mon, 24 Oct 2022 14:33:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 98DEB42B83; Mon, 24 Oct 2022 14:33:52 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2086.outbound.protection.outlook.com [40.107.220.86]) by mails.dpdk.org (Postfix) with ESMTP id 09D3340695; Mon, 24 Oct 2022 14:33:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WrDs78kNgbDvFqA9QTJATelmedUdiKCQ7iyyiiQ8/w4WFiWUdfKUeou6UmFVhkiSPOUxgHIrzwEfVIjyBOrMr7Ao9HOptuiCy3o4Vvv1BLOB8jrLQAEwUnefT08L/Wpkh5FBS2hI9tiGMBEg8Tmsk6rs77y7OQxqMBmt7qSYobpWms913C8vELY6iEZOy8RZCBuOVvPpU23Zz1A+ydRnC46T6Gt9pQRWqh//sHt4/JNeooM/uo6h2gKM3uGmvUoBjpjO2bek9fFszHaecStWMMaO9sEa/AaCiVgrbEJsOq8gzwlwGtVdLZKp7SwChLDtokFLUgjCBnkVbahAThlyNw== 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=rUO2VWVD8OxWXrnrJrGXxMz4ZheSbshV2s/kWFfA27Y=; b=S4erC/7wK1k5U+eaD5HCnB1cDYQOQLfro56JXaYvKKq/1zaf1Q8QHnSa9/D3f9VRzrGDKmFp2LVa8Uyo53JFfaTPnjT5RjzBqkO+F8JylYWTfKTYjy/WapwnSE+YG5ME2xceyfcXVSdVSvxU+2rz11Pyg9vGW+84VNmLchjM/zby6zRpJlzJhMoNacdYaE6+IP2u86t9o5UUHR/fSaa1Ee4VYRtkxo0YFgam5jmxb4eLnmGJloc/Bob1BkFMpwlCz52dX3POis5d9hlhscyLq4RP0kbt0cXyOuUa+VaCxSDNXUu4Lf66RkwJoPILEOFWfSL1Xsbqj6YPdLKWgqPKrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rUO2VWVD8OxWXrnrJrGXxMz4ZheSbshV2s/kWFfA27Y=; b=f67nZ8T1j03c5ycg8L4xLRnXOGfJ+goyQsFI+XSbaaqJTEZWKOz1JwMnqB0Mr307FOCNYHE4/FfoBlFGNjTcUuhFa9h7ii7pLfAp5wyGnJxbcH8ew4eLtKD2Z8n4ZsFTxzZ+J8NqRAM62Gxcs72el7gfKpYzsw0dzVPhH7auHTvBIxxdfGaszrZRWanGXqquQQcjJhq06wCHRrPrar0MfqywIUp6aQFUACwzOaQwk2PxaFBSeBMdJJBtn1Um+dsJkZr4Qn6oSr3sElEux6UO5TyY27CXmqkzdD5atlFBZWCSGpb42IKgZsEkwaZnLxKp+pMAo2EDPLEdOUTSs2EWtg== Received: from CY5PR15CA0222.namprd15.prod.outlook.com (2603:10b6:930:88::17) by DM4PR12MB5866.namprd12.prod.outlook.com (2603:10b6:8:65::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Mon, 24 Oct 2022 12:33:49 +0000 Received: from CY4PEPF0000B8EA.namprd05.prod.outlook.com (2603:10b6:930:88:cafe::41) by CY5PR15CA0222.outlook.office365.com (2603:10b6:930:88::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23 via Frontend Transport; Mon, 24 Oct 2022 12:33:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000B8EA.mail.protection.outlook.com (10.167.241.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20 via Frontend Transport; Mon, 24 Oct 2022 12:33:48 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 24 Oct 2022 05:33:43 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Mon, 24 Oct 2022 05:33:43 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29 via Frontend Transport; Mon, 24 Oct 2022 05:33:41 -0700 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , , Subject: [PATCH 1/2] common/mlx5: fix miss null check in devargs parsing Date: Mon, 24 Oct 2022 15:33:34 +0300 Message-ID: <20221024123335.3163331-2-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024123335.3163331-1-michaelba@nvidia.com> References: <20221024123335.3163331-1-michaelba@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000B8EA:EE_|DM4PR12MB5866:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f67dc6e-9f5e-46ce-3a87-08dab5bc002d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3VSE291nfsjXMzc6Lgny/uZLqy+inyAP5W/2EZo+YU5de3ZauOd2MNGMtWfmtx14qK6Q+AH4xd/qcqBUmIK495aAGrWShuZGDQuwTXyuiP6rMG4xfUZrSL5HuvuZFyA4alOfNhLh2I10Vy35/HOLR9Jkc51c04Q2WhoUQDxXFlfUeqFlBWbWlo4Gcl6UmbujRUTokBM9U+wPaVfYXhscVHceQ2RaPKTjxh/eWOo50LinWZ5AOL5cJRwn7MF0lx0lv1ZZE+m5q2yJgC4A/m4OkOVLLu2h56OdMXqUr2FWFkEKMXBhKFlH8HPtNCmG+ZfAai4Vu28o4w6XmwtK3NxFKhYRYvyntzsqYlkFe0Fs4j6YUo9qjqyEOur1fbjAAKG9fWUcjV1zQpziQi6cZ5tkq9ss0I4FVUBszSZcQ0Pl04JUoi1G3DVl3XI4Fz32NIKT1m4rlUVYlS8kJ/+IfPkPZ5w0mMjc+2Dj7TXJxT+otqePyNFGcp/5MIWvzZZYtMT6Fj6MOzsrDYqUzKGomyhqO9ooz1WmZNPDaiQr4jQWtR2zsbm4MZDTaJEBil/Ln7AMfdChJ6dejwJSiTuIh/7HwdjEfo+3bz+ccvO9y5R/KAUQdzqU9sL0ZMAsF8oFrt+Vmpr8v1wOKuTZi3/25DM7fubn8W0R7MCa4Aq438RmjabwPWtP7qKYR3WkFYR74dSecHD4NVCFfWhk8Q7c1zuWr4bBdcTn1qloG564x1tXeXGhpPpOB6CWum6b8f6Ic8lv/hfENLsgpGlBPvcRrDfC+NCXgwM95ywEciQSMREgKb8ReSVLedc0FYMUe/Y1laAB X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(136003)(376002)(39860400002)(396003)(346002)(451199015)(46966006)(40470700004)(36840700001)(8676002)(36860700001)(82740400003)(47076005)(36756003)(6666004)(450100002)(83380400001)(426003)(4326008)(478600001)(2906002)(54906003)(26005)(316002)(82310400005)(356005)(8936002)(40460700003)(41300700001)(6916009)(86362001)(40480700001)(55016003)(7636003)(2616005)(6286002)(7696005)(5660300002)(186003)(336012)(1076003)(70586007)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2022 12:33:48.6539 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f67dc6e-9f5e-46ce-3a87-08dab5bc002d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000B8EA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5866 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The common MLX5 probe function parses first the devargs and save them in a dictionary. It gets structure called "devargs" as a member of EAL device containing all needed information. When "devargs" structure is invalid, the function avoids parsing it. However, when it valid but its field "args" is invalid, the function tries to parse it and dereference to NULL pointer. This patch adds check to avoid this NULL dereferencing. Fixes: a729d2f093e9 ("common/mlx5: refactor devargs management") Cc: michaelba@nvidia.com Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_common.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 4dcc8cc49c..bf22c0694d 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -164,8 +164,9 @@ mlx5_kvargs_prepare(struct mlx5_kvargs_ctrl *mkvlist, struct rte_kvargs *kvlist; uint32_t i; - if (devargs == NULL) + if (mkvlist == NULL) return 0; + MLX5_ASSERT(devargs != NULL && devargs->args != NULL); kvlist = rte_kvargs_parse(devargs->args, NULL); if (kvlist == NULL) { rte_errno = EINVAL; @@ -400,8 +401,9 @@ parse_class_options(const struct rte_devargs *devargs, { int ret = 0; - if (devargs == NULL) + if (mkvlist == NULL) return 0; + MLX5_ASSERT(devargs != NULL); if (devargs->cls != NULL && devargs->cls->name != NULL) /* Global syntax, only one class type. */ return class_name_to_value(devargs->cls->name); @@ -965,7 +967,7 @@ mlx5_common_dev_probe(struct rte_device *eal_dev) int ret; DRV_LOG(INFO, "probe device \"%s\".", eal_dev->name); - if (eal_dev->devargs != NULL) + if (eal_dev->devargs != NULL && eal_dev->devargs->args != NULL) mkvlist_p = &mkvlist; ret = mlx5_kvargs_prepare(mkvlist_p, eal_dev->devargs); if (ret < 0) {