Skip to content

Commit

Permalink
iavf: validate pointers
Browse files Browse the repository at this point in the history
In some cases, the ethtool get_rxfh handler may be called with a null
key or indir parameter. So check these pointers, or you will have a very
bad day.

Fixes: 43a3d9b ("i40evf: Allow PF driver to configure RSS")
Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Tested-by: Tony Brelinski <tony.brelinski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
  • Loading branch information
Mitch Williams authored and Tony Nguyen committed Nov 15, 2021
1 parent 4f04008 commit 131b0ed
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions drivers/net/ethernet/intel/iavf/iavf_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1859,14 +1859,13 @@ static int iavf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,

if (hfunc)
*hfunc = ETH_RSS_HASH_TOP;
if (!indir)
return 0;

memcpy(key, adapter->rss_key, adapter->rss_key_size);
if (key)
memcpy(key, adapter->rss_key, adapter->rss_key_size);

/* Each 32 bits pointed by 'indir' is stored with a lut entry */
for (i = 0; i < adapter->rss_lut_size; i++)
indir[i] = (u32)adapter->rss_lut[i];
if (indir)
/* Each 32 bits pointed by 'indir' is stored with a lut entry */
for (i = 0; i < adapter->rss_lut_size; i++)
indir[i] = (u32)adapter->rss_lut[i];

return 0;
}
Expand Down

0 comments on commit 131b0ed

Please sign in to comment.