]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ethtool: rss: fix hkey leak when indir_size is 0
authorJakub Kicinski <kuba@kernel.org>
Fri, 22 May 2026 23:06:46 +0000 (16:06 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 26 May 2026 15:17:57 +0000 (08:17 -0700)
rss_get_data_alloc() allocates a single buffer that backs both the
indirection table and the hash key, but only assigned data->indir_table
when indir_size was nonzero. The expectation was that no driver
implements RSS without supporting indirection table but apparently
enic does just that (it's the only such in-tree driver).
enic has get_rxfh_key_size but no get_rxfh_indir_size.
data->indir_table stays as NULL, hkey gets set but rss_get_data_free()
kfree(data->indir_table) is a nop and the allocation leaks.

Always store the allocation base in data->indir_table so the free path
is unambiguous. No caller treats indir_table as a sentinel; everything
keys off indir_size.

Fixes: 7112a04664bf ("ethtool: add netlink based get rss support")
Link: https://patch.msgid.link/20260522230647.1705600-6-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ethtool/rss.c

index 9fb675d2923264d7c0d9aee7057558ccbffda8f7..f5cf214f8f85f75b121cd331c2ac932f8be3aca9 100644 (file)
@@ -134,8 +134,7 @@ rss_get_data_alloc(struct net_device *dev, struct rss_reply_data *data)
        if (!rss_config)
                return -ENOMEM;
 
-       if (data->indir_size)
-               data->indir_table = (u32 *)rss_config;
+       data->indir_table = (u32 *)rss_config;
        if (data->hkey_size)
                data->hkey = rss_config + indir_bytes;