From patchwork Mon Feb 11 03:35:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 1039582 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="ICF0QRxX"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43yWh21hyMz9s5c for ; Mon, 11 Feb 2019 14:37:38 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbfBKDhg (ORCPT ); Sun, 10 Feb 2019 22:37:36 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:36777 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbfBKDhf (ORCPT ); Sun, 10 Feb 2019 22:37:35 -0500 Received: by mail-qk1-f194.google.com with SMTP id o125so5655561qkf.3 for ; Sun, 10 Feb 2019 19:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dp3N7VTQQUerRYfbfvsZUnmYTsZJzMliESMQTAbIzuA=; b=ICF0QRxXs5gAxCR7M3J/rqMi4IsrxmyDAHfIl+BSvEc8Sq0tKEqOKdu/ctx27rIq9e NJJhQ4bztEOHYrwD5jbrHy1qEfOh6YPlLM01uwlAWzabfWglG+REJdayjSgcSV6Qhyas zmOv5btlKSh4ns6Hb7Cp/oQxgUh+ow4HQkhnxN+pc33WQDXsgvgFLK1zQr/zFYkUU58c MKJE/GSWi53hhZ69VTmGa6Nt2Y3EA1qGg3CucIDBH9V7Egr+dnKLNtS2AqLSmFrS05jL 308l41XrLB39UgrZcDrw9U10UZWEf8AQSH+ew4/6nIC7mHelA8Xub2hfE/ZL19uOD/kI EA1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dp3N7VTQQUerRYfbfvsZUnmYTsZJzMliESMQTAbIzuA=; b=mB7eAl5hPge9xKcvIVG94i2X6wLBcrQLAbo7EQUSOrIl/3hsW4/GSCT/fP1ToFg9xe egT8GCqXymQN+s8mPABsTs1+ftt/TTragjujbrEcoaidSL0oklAlB47sIk7q++kSdpHS eVrHj3iGWb8nx3EPoq6Kuc4SxQrfAOOAgMvyJqh1J+Jo1SrEscnhJD6UwIMkOtV0fgOq DNeJaFkLw4lEEPPATloqVZ3k1Mk8Uhnx614BDQcmiO2wbH5xqVfPqlmGanmou9fRgF6s ZF9QPi3RXIN+3T06teCC27EMEkeM62UDQLKNxvOih7K0DXtk3rhnDPz8Bp7Bqj9dcCsb z3MA== X-Gm-Message-State: AHQUAuZTplR2xFeuVeQcew9xcnqAXS8peNc3+2f/0W4X225aifiz38+j sZ646KpwtNbY2hgnQhKsx05xUA== X-Google-Smtp-Source: AHgI3IZLiqCWvfi0pad/kRY/l59MXzmGK2bp3qhcxfXnlAcmCD8+Yjd/EhbkIdrvI26+nYRb0QvtWA== X-Received: by 2002:a37:9cd1:: with SMTP id f200mr24015024qke.176.1549856254106; Sun, 10 Feb 2019 19:37:34 -0800 (PST) Received: from jkicinski-Precision-T1700.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id d63sm24689266qka.22.2019.02.10.19.37.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 19:37:33 -0800 (PST) From: Jakub Kicinski To: davem@davemloft.net, jiri@resnulli.us Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, Jakub Kicinski Subject: [PATCH net-next v2 2/5] devlink: don't allocate attrs on the stack Date: Sun, 10 Feb 2019 19:35:28 -0800 Message-Id: <20190211033531.12928-3-jakub.kicinski@netronome.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190211033531.12928-1-jakub.kicinski@netronome.com> References: <20190211033531.12928-1-jakub.kicinski@netronome.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Number of devlink attributes has grown over 128, causing the following warning: ../net/core/devlink.c: In function ‘devlink_nl_cmd_region_read_dumpit’: ../net/core/devlink.c:3740:1: warning: the frame size of 1064 bytes is larger than 1024 bytes [-Wframe-larger-than=] } ^ Since the number of attributes is only going to grow allocate the array dynamically. Signed-off-by: Jakub Kicinski Acked-by: Jiri Pirko --- net/core/devlink.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index cf0f511bc56c..46c468a1f3dc 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -3629,26 +3629,30 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, struct netlink_callback *cb) { u64 ret_offset, start_offset, end_offset = 0; - struct nlattr *attrs[DEVLINK_ATTR_MAX + 1]; const struct genl_ops *ops = cb->data; struct devlink_region *region; struct nlattr *chunks_attr; const char *region_name; struct devlink *devlink; + struct nlattr **attrs; bool dump = true; void *hdr; int err; start_offset = *((u64 *)&cb->args[0]); + attrs = kmalloc_array(DEVLINK_ATTR_MAX + 1, sizeof(*attrs), GFP_KERNEL); + if (!attrs) + return -ENOMEM; + err = nlmsg_parse(cb->nlh, GENL_HDRLEN + devlink_nl_family.hdrsize, attrs, DEVLINK_ATTR_MAX, ops->policy, cb->extack); if (err) - goto out; + goto out_free; devlink = devlink_get_from_attrs(sock_net(cb->skb->sk), attrs); if (IS_ERR(devlink)) - goto out; + goto out_free; mutex_lock(&devlink_mutex); mutex_lock(&devlink->lock); @@ -3710,6 +3714,7 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, genlmsg_end(skb, hdr); mutex_unlock(&devlink->lock); mutex_unlock(&devlink_mutex); + kfree(attrs); return skb->len; @@ -3718,7 +3723,8 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, out_unlock: mutex_unlock(&devlink->lock); mutex_unlock(&devlink_mutex); -out: +out_free: + kfree(attrs); return 0; }