@@ -3642,7 +3642,7 @@ static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs)
3642
3642
if (vi -> has_rss && !netif_is_rxfh_configured (dev )) {
3643
3643
old_rss_hdr = vi -> rss_hdr ;
3644
3644
old_rss_trailer = vi -> rss_trailer ;
3645
- vi -> rss_hdr = kzalloc ( virtnet_rss_hdr_size (vi ), GFP_KERNEL );
3645
+ vi -> rss_hdr = devm_kzalloc ( & dev -> dev , virtnet_rss_hdr_size (vi ), GFP_KERNEL );
3646
3646
if (!vi -> rss_hdr ) {
3647
3647
vi -> rss_hdr = old_rss_hdr ;
3648
3648
return - ENOMEM ;
@@ -3653,15 +3653,15 @@ static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs)
3653
3653
3654
3654
if (!virtnet_commit_rss_command (vi )) {
3655
3655
/* restore ctrl_rss if commit_rss_command failed */
3656
- kfree ( vi -> rss_hdr );
3656
+ devm_kfree ( & dev -> dev , vi -> rss_hdr );
3657
3657
vi -> rss_hdr = old_rss_hdr ;
3658
3658
vi -> rss_trailer = old_rss_trailer ;
3659
3659
3660
3660
dev_warn (& dev -> dev , "Fail to set num of queue pairs to %d, because committing RSS failed\n" ,
3661
3661
queue_pairs );
3662
3662
return - EINVAL ;
3663
3663
}
3664
- kfree ( old_rss_hdr );
3664
+ devm_kfree ( & dev -> dev , old_rss_hdr );
3665
3665
goto succ ;
3666
3666
}
3667
3667
@@ -6768,7 +6768,7 @@ static int virtnet_probe(struct virtio_device *vdev)
6768
6768
virtio_cread16 (vdev , offsetof(struct virtio_net_config ,
6769
6769
rss_max_indirection_table_length ));
6770
6770
}
6771
- vi -> rss_hdr = kzalloc ( virtnet_rss_hdr_size (vi ), GFP_KERNEL );
6771
+ vi -> rss_hdr = devm_kzalloc ( & vdev -> dev , virtnet_rss_hdr_size (vi ), GFP_KERNEL );
6772
6772
if (!vi -> rss_hdr ) {
6773
6773
err = - ENOMEM ;
6774
6774
goto free ;
@@ -7051,8 +7051,6 @@ static void virtnet_remove(struct virtio_device *vdev)
7051
7051
7052
7052
remove_vq_common (vi );
7053
7053
7054
- kfree (vi -> rss_hdr );
7055
-
7056
7054
free_netdev (vi -> dev );
7057
7055
}
7058
7056
0 commit comments