From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DF556A0093; Mon, 7 Nov 2022 11:09:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7FED740156; Mon, 7 Nov 2022 11:09:25 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2051.outbound.protection.outlook.com [40.107.223.51]) by mails.dpdk.org (Postfix) with ESMTP id 1FCCC40151 for ; Mon, 7 Nov 2022 11:09:24 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q7CjhANVDc0qQCYIvIa9ARNNqA+aYxo9zYvO1sJCXn5woEdPwJX1YBojtW1MgZo4UogLRdQRfXlgmnDd2+znvDGKk35bK6/VdhQbRJv7REqysws9VQM7T2st81hlTup7oxYAF44m47BPiKS9bEHkYo9NcTDuCdBcJ3Z5y2aQuQJicOodTJwe5BALXYxPNSJSSd1b2IfosxZPWwcB66Rje9AM9b8Yd9QKMKP/GRcvTUHjlxiEJI6PNny9NzAcpmrt3BQQWdphHUoWduSOvLwGmNYt+RZvVL3BURALU+pgNOjwRT1k31efh7OTvJ1Pe4S4zWzwUYUl9NDlDXjkA3CiJA== 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=7016N9cQChHsNNtgbdWdkBi5Yb0RcX6gHVTrPytrGOs=; b=CJWAMjmpf8qx4XeuVfDPQfwDvQdstwUVRf4S92/fLtvu20DPUUY/rSJ77djjbk0pgeksyHCWZd9M8MbajPzU4ijx7ETmo5Qwep3V5OfwqPyvzJnJ4UYGrsKpwk5wJbznUURn5I2PG9wyMBungcdp3Ld/ZtxCdSk68GQTYL8qYmG+7t1Qe+p+SFSS4RV83odWk4kCCgkFw2m+Kk4s2bWCgmvmgkjz5yB2Nepp7JqaHAaDcuuVpHlZk6dzXvhTI8JkTPftx5eqSAYWXjC8KB5daju0EizY7siH9NbYJqSn4EFAWU28XR2MPGo4yhqRmmu3CH5licglEkK3bWSCniwlxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=monjalon.net 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=7016N9cQChHsNNtgbdWdkBi5Yb0RcX6gHVTrPytrGOs=; b=N4JYqWUMddcTJapAorwBvg3/IKSQS1Bz07QPXCY2BoAktbod355C5tbIu75s7h+VnNdCS0nh4f3lIz1i//4NeK59HuNMUySMsBRSIAlmtzl9SYLzrGhCogN3hhciPtGwATlQzwQU06BaZfPBU8sQb8x7IyEu5zg9U9OYza4bgG+/uMLLIElj1xTsexcXHALuQHpOAPoXv0vZo91KYxhR/NW6Xza3KgSImmu9VWlBR46ZP6PSG0Bxr+8ROrjNblqq47ffczqAJQtZv9+RK8MSipiXu8GwrFiYFW6M0rv4fyZ2mpa5v9M7uLnZ6ItrK1e4+15f+2SciUv2ypIft0i/Dw== Received: from BN9PR03CA0978.namprd03.prod.outlook.com (2603:10b6:408:109::23) by DM4PR12MB5357.namprd12.prod.outlook.com (2603:10b6:5:39b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.25; Mon, 7 Nov 2022 10:09:22 +0000 Received: from BN8NAM11FT093.eop-nam11.prod.protection.outlook.com (2603:10b6:408:109:cafe::cb) by BN9PR03CA0978.outlook.office365.com (2603:10b6:408:109::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.26 via Frontend Transport; Mon, 7 Nov 2022 10:09:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT093.mail.protection.outlook.com (10.13.177.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20 via Frontend Transport; Mon, 7 Nov 2022 10:09:22 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 7 Nov 2022 02:09:09 -0800 Received: from nvidia.com (10.126.230.35) 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, 7 Nov 2022 02:09:06 -0800 From: Alex Vesker To: , , , , Matan Azrad CC: , Subject: [PATCH] net/mlx5/hws: fix possible negative return on sq create Date: Mon, 7 Nov 2022 12:08:51 +0200 Message-ID: <20221107100851.15644-1-valex@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20221103125146.7291-1-valex@nvidia.com> References: <20221103125146.7291-1-valex@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT093:EE_|DM4PR12MB5357:EE_ X-MS-Office365-Filtering-Correlation-Id: ec90db2b-8dd2-4eab-9805-08dac0a8245e X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TfOWZn1TgY0mKKTEQynJVbuUUyJCo5T/uSeUaZM93OYFyT2e+XLxLOLm6Ggka1AKyl8C8D4JoZwtajFGgeQ51r6/P29ziv9iEgrizj+HnZD4SKF+wQfAvziig3o1NJCzFOfvWPkU7UMqQGK+d+bnQd9TiZJLrZVVEeyzMEelNMfSFXbNjoIgQvZxzPLxNp/cSMP1OyWZZwnFtgG3lUtqRXBTICK/iQ9Wn5T0HFaU6kQ1N1oM5BIVgOoDaQHd61BbubCrBLQ04DH3riJimldq7zPVjqyNld1k6xJ7/5i0vI1R3PSu8KEgBKJhguKGEK90BbL2yDondEh6fCBJbaOp8pqxdRWkPdUkRCwaqTCn6EJYWAdO3r0C0blLSXnwq1lMDOXseYVqxKukSFfbACc+Bh+kwPTTit0+8qDLXhSSpUFwRT/XXBjdCzNMgtWTzSA2k9E7kRIYs5688vOnPmGAre1IZWLKgWry9/mhfghuNkJ2K+uMmbTI3+jpg/wuqas6+O46s7Gmeq9cHLi/RXiETTvoysTp+CnXxmaLYYDT2l1F8Y8TUwgsPhF4UBtaj8oBf4ElB+WeDHG6l3JPmAVtmFIEMWrQdkmZOH9Mlnhj96DDkjH3tZdm1If1WT4DzW2Zzqcip5yCtoVvEtuSLggAV83atLxr1tmSe22Ez2EMfU7/SH5Jd4p9tgwRTMMDFwuzPByRFEca9lBDsgaTNmLYZT20m0FHQd1MRRcvM/QB3Fb4NgHrNM/wD3ni3MUeqlpI1ITm+6sRNcBvs5WPzk4AsQ== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(346002)(396003)(376002)(39860400002)(136003)(451199015)(40470700004)(46966006)(36840700001)(70586007)(83380400001)(4326008)(36756003)(8676002)(70206006)(47076005)(426003)(2906002)(336012)(356005)(86362001)(107886003)(316002)(7636003)(54906003)(6636002)(110136005)(6666004)(82310400005)(40460700003)(36860700001)(7696005)(82740400003)(40480700001)(2616005)(26005)(5660300002)(478600001)(6286002)(8936002)(41300700001)(186003)(16526019)(1076003)(55016003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2022 10:09:22.1533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec90db2b-8dd2-4eab-9805-08dac0a8245e 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT093.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5357 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 sysconf call can return a negative value (-1) on failure this will lead to posix_memalign to fail. This is not a realistic case which was found by the static checkers. Coverity issue: 381674 Fixes: 3eb7488 ("net/mlx5/hws: add send layer") Signed-off-by: Alex Vesker Reviewed-by: Erez Shitrit Acked-by: Matan Azrad --- drivers/net/mlx5/hws/mlx5dr_send.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_send.c b/drivers/net/mlx5/hws/mlx5dr_send.c index 26904a9040..1e9953a38f 100644 --- a/drivers/net/mlx5/hws/mlx5dr_send.c +++ b/drivers/net/mlx5/hws/mlx5dr_send.c @@ -524,6 +524,7 @@ static int mlx5dr_send_ring_open_sq(struct mlx5dr_context *ctx, size_t sq_log_buf_sz; size_t buf_aligned; size_t sq_buf_sz; + size_t page_size; size_t buf_sz; int err; @@ -532,8 +533,9 @@ static int mlx5dr_send_ring_open_sq(struct mlx5dr_context *ctx, sq_buf_sz = 1 << (sq_log_buf_sz + log2above(MLX5_SEND_WQE_BB)); sq->reg_addr = queue->uar->reg_addr; - buf_aligned = align(sq_buf_sz, sysconf(_SC_PAGESIZE)); - err = posix_memalign((void **)&sq->buf, sysconf(_SC_PAGESIZE), buf_aligned); + page_size = sysconf(_SC_PAGESIZE); + buf_aligned = align(sq_buf_sz, page_size); + err = posix_memalign((void **)&sq->buf, page_size, buf_aligned); if (err) { rte_errno = ENOMEM; return err; -- 2.18.1