Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1839751pxb; Mon, 8 Mar 2021 07:35:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyso2xZVbLP10p2skVv30P1+rb2SetSsRFhYxEHNrzKB9xjz1cxi1DqTN/Y9Csr5J1O6Him X-Received: by 2002:a17:907:33c6:: with SMTP id zk6mr12444772ejb.228.1615217735480; Mon, 08 Mar 2021 07:35:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615217735; cv=none; d=google.com; s=arc-20160816; b=WamrX7PgzdSOqUc5h3GWRiA/nMEhXWHsvQPVFZluEwTZcXzozULC+KUkkgN3beBDK0 lpXY5IwIjG8PKSl4vv7y0I/zOVXTHiuPdhL4hJWfVDnI4cH2VKj6VNRyB3/2ZgGytMr/ EFZTBRBz8Bxzj0Bk4kDt0ZWw8C/ODj5dFidHNry2je2lKVyQS6aR8XvLSuKylXK3UeDj NYVCNKSo4iaPeE5ORu57kEbZcC3KxTgs6WNjZt1chTkx0nwauniLMDfOncqmfvu2fFsW cdEmNbwuT7OZLTfNCOvYextsYUSp/0I1WhNouuTaPRHo6v+ipcA8pmux1N2smE31tXFS Tkdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SePTOUIaft+zg1MNYoy4Xc//qwPIW8fEP7yX5DwQZLU=; b=ZYX6s0On5WZzBmAKWpRn5t7wb6fBIcvI+F1MO56PLZ/lN+ViRTkO422TXbHtNjdrJm U8XQ5oUzv4cE3pC1Qn3EI6v4YgIox9QsrN8ABUfSiLT+iTZIUzOmj6PSRqKqV8PEtwQC IrrMRC1WmAtzl/FADDRAMfVjDH57eE8L2IGfDQtGnxlaKmaiyajdxU1620TU+3js3zSx q47ql5pNSEg/f3mMAcxRWqVop36Oykwa8jKnHnkytV7eJmfnS+4xlejNc6B4yYU07TuZ 6gzXmjjMaO553hLv1pPdeCeDcGC+PP4yect2atSh3qrcRIgHAuqSt/Pcj5f/ymNj4YOu uyRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q7OA0wqv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hb26si7255671ejb.144.2021.03.08.07.35.12; Mon, 08 Mar 2021 07:35:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q7OA0wqv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230327AbhCHPde (ORCPT + 99 others); Mon, 8 Mar 2021 10:33:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:60680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbhCHPdZ (ORCPT ); Mon, 8 Mar 2021 10:33:25 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F28D56526A; Mon, 8 Mar 2021 15:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615217604; bh=UdgGpH5wigD4IDua1jI0Goj5nN066h+PRHihFx2waQY=; h=From:To:Cc:Subject:Date:From; b=q7OA0wqvAqQ/DPTVQ5yPBYKh3QOKEgYVJc/zfgupO+rvPAuhdHTnzdGOnmt73HJQ3 gS2efyZ2zIvJ3j+fpB+2AHpFYtAQbntLL3hOh+h3RhjsuJEtycG5+8YqTOJ4SOVzZZ OfMJIOVDHXR38lFFE2hYCizVE53huLTBgO2KEkrkWnbad/CWlcXxifwSXwijz4xI/d J3b6Htz08n43ghbK3pmUnnAMwX0g3MoXSEbryI7Ex3BffKRY6Sb0oYKXzpjaxEB1G8 1CVf/xYxuG8bDYhFcOJhKsEdXho9ka58QwILGAwT+EBRVMUUDmDofr/P0nh+UCy6kt ix8JOz166XrxA== From: Arnd Bergmann To: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Jakub Kicinski , Tariq Toukan , Noam Stolero , Tal Gilboa Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Roi Dayan , Vlad Buslov , Paul Blakey , Oz Shlomo , Eli Cohen , Ariel Levkovich , Maor Dickman , Tariq Toukan , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] net/mlx5e: allocate 'indirection_rqt' buffer dynamically Date: Mon, 8 Mar 2021 16:32:57 +0100 Message-Id: <20210308153318.2486939-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann Increasing the size of the indirection_rqt array from 128 to 256 bytes pushed the stack usage of the mlx5e_hairpin_fill_rqt_rqns() function over the warning limit when building with clang and CONFIG_KASAN: drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:970:1: error: stack frame size of 1180 bytes in function 'mlx5e_tc_add_nic_flow' [-Werror,-Wframe-larger-than=] Using dynamic allocation here is safe because the caller does the same, and it reduces the stack usage of the function to just a few bytes. Fixes: 1dd55ba2fb70 ("net/mlx5e: Increase indirection RQ table size to 256") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 0da69b98f38f..66f98618dc13 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -445,12 +445,16 @@ static void mlx5e_hairpin_destroy_transport(struct mlx5e_hairpin *hp) mlx5_core_dealloc_transport_domain(hp->func_mdev, hp->tdn); } -static void mlx5e_hairpin_fill_rqt_rqns(struct mlx5e_hairpin *hp, void *rqtc) +static int mlx5e_hairpin_fill_rqt_rqns(struct mlx5e_hairpin *hp, void *rqtc) { - u32 indirection_rqt[MLX5E_INDIR_RQT_SIZE], rqn; + u32 *indirection_rqt, rqn; struct mlx5e_priv *priv = hp->func_priv; int i, ix, sz = MLX5E_INDIR_RQT_SIZE; + indirection_rqt = kzalloc(sz, GFP_KERNEL); + if (!indirection_rqt) + return -ENOMEM; + mlx5e_build_default_indir_rqt(indirection_rqt, sz, hp->num_channels); @@ -462,6 +466,9 @@ static void mlx5e_hairpin_fill_rqt_rqns(struct mlx5e_hairpin *hp, void *rqtc) rqn = hp->pair->rqn[ix]; MLX5_SET(rqtc, rqtc, rq_num[i], rqn); } + + kfree(indirection_rqt); + return 0; } static int mlx5e_hairpin_create_indirect_rqt(struct mlx5e_hairpin *hp) @@ -482,12 +489,15 @@ static int mlx5e_hairpin_create_indirect_rqt(struct mlx5e_hairpin *hp) MLX5_SET(rqtc, rqtc, rqt_actual_size, sz); MLX5_SET(rqtc, rqtc, rqt_max_size, sz); - mlx5e_hairpin_fill_rqt_rqns(hp, rqtc); + err = mlx5e_hairpin_fill_rqt_rqns(hp, rqtc); + if (err) + goto out; err = mlx5_core_create_rqt(mdev, in, inlen, &hp->indir_rqt.rqtn); if (!err) hp->indir_rqt.enabled = true; +out: kvfree(in); return err; } -- 2.29.2