hinic: fix leak of ethtool RSS user configuration buffers
Subsystems (3)
PATCH 1/1 hinic: fix leak of ethtool RSS user configuration buffers
From: Chenguang Zhao <[email protected]>
rss_indir_user and rss_hkey_user are allocated in __set_rss_rxfh() when the user configures RSS via ethtool, but hinic_remove() never frees them. free_netdev() only releases the nic_dev structure itself, so the separately allocated buffers are leaked on driver unload.
Free both buffers in hinic_remove() after unregister_netdev().
--- drivers/net/ethernet/huawei/hinic/hinic_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/huawei/hinic/hinic_main.c +3 -0
@@ -1433,6 +1433,9 @@ static void hinic_remove(struct pci_dev *pdev)hinic_free_intr_coalesce (nic_dev); +kfree (nic_dev->rss_indir_user); +kfree (nic_dev->rss_hkey_user); +hinic_port_del_mac (nic_dev, netdev->dev_addr,0 ); hinic_hwdev_cb_unregister(nic_dev->hwdev,
Signature · 1 line
2.25.1
Quoted 20 lines · Chenguang Zhao
From: Chenguang Zhao <[email protected]>
rss_indir_userandrss_hkey_userare allocated in__set_rss_rxfh()when the user configures RSS via ethtool, buthinic_remove()never frees them.free_netdev()only releases thenic_devstructure itself, so the separately allocated buffers are leaked on driver unload.Free both buffers in
hinic_remove()afterunregister_netdev().Fixes 4fdc51bb4e92 ("hinic: add support for rss parameters with ethtool")Signed-off-by Chenguang Zhao <[email protected]>--- drivers/net/ethernet/huawei/hinic/hinic_main.c | 3 +++ 1 file changed, 3 insertions(+)drivers/net/ethernet/huawei/hinic/hinic_main.c +0
-0
drivers/net/ethernet/huawei/hinic/hinic_main.c static void hinic_remove(struct pci_dev *pdev) · line 1438
Quoted 6 lines
drivers/net/ethernet/huawei/hinic/hinic_main.c +3
-0@@ -1433,6 +1433,9 @@ static void hinic_remove(struct pci_dev *pdev)hinic_free_intr_coalesce (nic_dev); +kfree (nic_dev->rss_indir_user); +kfree (nic_dev->rss_hkey_user); +
I scanned the code and ... maybe I got this wrong ... but it looks like nothing actually uses these fields?
If you look at hinic_ethtool.c, the buffers are allocated, data is copied into them and then they are never used. hinic_get_rxfh seems to read the state directly from the device ?
I wonder if the correct fix is to drop the buffers and the memcpys entirely because they seem unnecessary and unused.