From patchwork Wed Mar 10 19:03:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 12129127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FE7CC4161F for ; Wed, 10 Mar 2021 19:04:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2827D64E98 for ; Wed, 10 Mar 2021 19:04:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233725AbhCJTEY (ORCPT ); Wed, 10 Mar 2021 14:04:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:44420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233766AbhCJTEC (ORCPT ); Wed, 10 Mar 2021 14:04:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3F83C64FD0; Wed, 10 Mar 2021 19:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615403042; bh=GUnko2cH/KeDbj/s3T5xHycJYzy2NsWuBKqlpQY9zqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BnAmQCRZGTCU9DASkTg/4dJhUjqEFFWNBlMQFjKreYbKS8DdijnhnJYok40f+BdRJ WDn1o9n7u8KenHMS9KpVzRhmwpyon8Hrs0GlHv8JpLjHyIHsdPbMr7dJEdeC+tGweT QyKihNUb1I8W/snjUC4KQAmEz1RmjDYhSgKfBqkrgQgkdkCcMv3yxGOtW6RQY6rmfW 3W63oMY4aIkaSq3qEpburTh+gkasNiogu2BTTwfUJIIQkyupXrqZtW+Wxddxz64JZL ZN3PdkFG83gWg43gGk/Z/xuVCQttPy7ZT4/02YKj43ZEGmk8ZamU4dwrLAuTFRcAhS nnUrv29HUGoYg== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, Shay Drory , Parav Pandit , Saeed Mahameed Subject: [net 17/18] net/mlx5: SF: Fix error flow of SFs allocation flow Date: Wed, 10 Mar 2021 11:03:41 -0800 Message-Id: <20210310190342.238957-18-saeed@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210310190342.238957-1-saeed@kernel.org> References: <20210310190342.238957-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shay Drory When SF id is unavailable, code jumps to wrong label that accesses sw id array outside of its range. Hence, when SF id is not allocated, avoid accessing such array. Fixes: 8f0105418668 ("net/mlx5: SF, Add port add delete functionality") Signed-off-by: Shay Drory Reviewed-by: Parav Pandit Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c index 58b6be0b03d7..0914909806cb 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c @@ -64,7 +64,7 @@ int mlx5_sf_hw_table_sf_alloc(struct mlx5_core_dev *dev, u32 usr_sfnum) } if (sw_id == -ENOSPC) { err = -ENOSPC; - goto err; + goto exist_err; } hw_fn_id = mlx5_sf_sw_to_hw_id(table->dev, sw_id);