[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20231208175703.3970d1de@kernel.org>
Date: Fri, 8 Dec 2023 17:57:03 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Ahmed Zaki <ahmed.zaki@...el.com>
Cc: netdev@...r.kernel.org, intel-wired-lan@...ts.osuosl.org,
corbet@....net, jesse.brandeburg@...el.com, anthony.l.nguyen@...el.com,
davem@...emloft.net, edumazet@...gle.com, pabeni@...hat.com,
vladimir.oltean@....com, andrew@...n.ch, horms@...nel.org,
mkubecek@...e.cz, willemdebruijn.kernel@...il.com, gal@...dia.com,
alexander.duyck@...il.com, ecree.xilinx@...il.com,
linux-doc@...r.kernel.org, Jacob Keller <jacob.e.keller@...el.com>
Subject: Re: [PATCH net-next v8 1/8] net: ethtool: pass a pointer to
parameters to get/set_rxfh ethtool ops
On Wed, 6 Dec 2023 16:36:35 -0700 Ahmed Zaki wrote:
> - rxfh.indir_size = dev_indir_size;
> - rxfh.key_size = dev_key_size;
> + rxfh.indir_size = rxfh_dev.indir_size;
> + rxfh.key_size = rxfh_dev.key_size;
> if (copy_to_user(useraddr, &rxfh, sizeof(rxfh)))
> return -EFAULT;
>
> - if ((user_indir_size && (user_indir_size != dev_indir_size)) ||
> - (user_key_size && (user_key_size != dev_key_size)))
> + if ((user_indir_size && user_indir_size != rxfh_dev.indir_size) ||
> + (user_key_size && user_key_size != rxfh_dev.key_size))
> return -EINVAL;
>
> - indir_bytes = user_indir_size * sizeof(indir[0]);
> - total_size = indir_bytes + user_key_size;
> - rss_config = kzalloc(total_size, GFP_USER);
> - if (!rss_config)
> - return -ENOMEM;
> -
> - if (user_indir_size)
> - indir = (u32 *)rss_config;
> + indir_bytes = user_indir_size * sizeof(*rxfh_dev.indir);
> + if (indir_bytes) {
> + rxfh_dev.indir = kzalloc(indir_bytes, GFP_KERNEL);
> + if (!rxfh_dev.indir)
> + return -ENOMEM;
> + }
>
> - if (user_key_size)
> - hkey = rss_config + indir_bytes;
> + if (user_key_size) {
> + rxfh_dev.key = kzalloc(user_key_size, GFP_KERNEL);
> + if (!rxfh_dev.key) {
> + kfree(rxfh_dev.indir);
> + return -ENOMEM;
> + }
> + }
Splitting the allocation into two separate kzalloc()s should be
a separate change.
> +struct ethtool_rxfh_param {
> + __u8 hfunc;
> + __u32 indir_size;
> + __u32 *indir;
> + __u32 key_size;
> + __u8 *key;
> +};
no underscores needed on types, this is a kernel struct
Powered by blists - more mailing lists