1. pcaps are free'd right after AQ routines are done, no need for
   devm_'s
2. a test frame for loopback test in ethtool -t is destroyed at the end
   of the test so we don't need devm_ here either.

Signed-off-by: Maciej Fijalkowski <[email protected]>
---
 drivers/net/ethernet/intel/ice/ice_common.c  | 34 +++++++-------------
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 10 ++----
 2 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_common.c 
b/drivers/net/ethernet/intel/ice/ice_common.c
index 10c32cd80fff..a987dc063946 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -965,9 +965,9 @@ static void ice_get_itr_intrl_gran(struct ice_hw *hw)
  */
 int ice_init_hw(struct ice_hw *hw)
 {
-       struct ice_aqc_get_phy_caps_data *pcaps;
+       struct ice_aqc_get_phy_caps_data *pcaps __free(kfree);
+       void *mac_buf __free(kfree);
        u16 mac_buf_len;
-       void *mac_buf;
        int status;
 
        /* Set MAC type based on DeviceID */
@@ -1045,7 +1045,7 @@ int ice_init_hw(struct ice_hw *hw)
        if (status)
                goto err_unroll_sched;
 
-       pcaps = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*pcaps), GFP_KERNEL);
+       pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
        if (!pcaps) {
                status = -ENOMEM;
                goto err_unroll_sched;
@@ -1055,7 +1055,6 @@ int ice_init_hw(struct ice_hw *hw)
        status = ice_aq_get_phy_caps(hw->port_info, false,
                                     ICE_AQC_REPORT_TOPO_CAP_MEDIA, pcaps,
                                     NULL);
-       devm_kfree(ice_hw_to_dev(hw), pcaps);
        if (status)
                dev_warn(ice_hw_to_dev(hw), "Get PHY capabilities failed status 
= %d, continuing anyway\n",
                         status);
@@ -1082,18 +1081,15 @@ int ice_init_hw(struct ice_hw *hw)
 
        /* Get MAC information */
        /* A single port can report up to two (LAN and WoL) addresses */
-       mac_buf = devm_kcalloc(ice_hw_to_dev(hw), 2,
-                              sizeof(struct ice_aqc_manage_mac_read_resp),
-                              GFP_KERNEL);
-       mac_buf_len = 2 * sizeof(struct ice_aqc_manage_mac_read_resp);
-
+       mac_buf = kcalloc(2, sizeof(struct ice_aqc_manage_mac_read_resp),
+                         GFP_KERNEL);
        if (!mac_buf) {
                status = -ENOMEM;
                goto err_unroll_fltr_mgmt_struct;
        }
 
+       mac_buf_len = 2 * sizeof(struct ice_aqc_manage_mac_read_resp);
        status = ice_aq_manage_mac_read(hw, mac_buf, mac_buf_len, NULL);
-       devm_kfree(ice_hw_to_dev(hw), mac_buf);
 
        if (status)
                goto err_unroll_fltr_mgmt_struct;
@@ -3240,19 +3236,14 @@ int ice_update_link_info(struct ice_port_info *pi)
                return status;
 
        if (li->link_info & ICE_AQ_MEDIA_AVAILABLE) {
-               struct ice_aqc_get_phy_caps_data *pcaps;
-               struct ice_hw *hw;
+               struct ice_aqc_get_phy_caps_data *pcaps __free(kfree);
 
-               hw = pi->hw;
-               pcaps = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*pcaps),
-                                    GFP_KERNEL);
+               pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
                if (!pcaps)
                        return -ENOMEM;
 
                status = ice_aq_get_phy_caps(pi, false, 
ICE_AQC_REPORT_TOPO_CAP_MEDIA,
                                             pcaps, NULL);
-
-               devm_kfree(ice_hw_to_dev(hw), pcaps);
        }
 
        return status;
@@ -3393,8 +3384,8 @@ ice_cfg_phy_fc(struct ice_port_info *pi, struct 
ice_aqc_set_phy_cfg_data *cfg,
 int
 ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool 
ena_auto_link_update)
 {
+       struct ice_aqc_get_phy_caps_data *pcaps __free(kfree);
        struct ice_aqc_set_phy_cfg_data cfg = { 0 };
-       struct ice_aqc_get_phy_caps_data *pcaps;
        struct ice_hw *hw;
        int status;
 
@@ -3404,7 +3395,7 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, 
bool ena_auto_link_update)
        *aq_failures = 0;
        hw = pi->hw;
 
-       pcaps = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*pcaps), GFP_KERNEL);
+       pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
        if (!pcaps)
                return -ENOMEM;
 
@@ -3456,7 +3447,6 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, 
bool ena_auto_link_update)
        }
 
 out:
-       devm_kfree(ice_hw_to_dev(hw), pcaps);
        return status;
 }
 
@@ -3535,7 +3525,7 @@ int
 ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
                enum ice_fec_mode fec)
 {
-       struct ice_aqc_get_phy_caps_data *pcaps;
+       struct ice_aqc_get_phy_caps_data *pcaps __free(kfree);
        struct ice_hw *hw;
        int status;
 
@@ -3604,8 +3594,6 @@ ice_cfg_phy_fec(struct ice_port_info *pi, struct 
ice_aqc_set_phy_cfg_data *cfg,
        }
 
 out:
-       kfree(pcaps);
-
        return status;
 }
 
diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c 
b/drivers/net/ethernet/intel/ice/ice_ethtool.c
index a19b06f18e40..8a260a468a81 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
@@ -801,7 +801,7 @@ static int ice_lbtest_create_frame(struct ice_pf *pf, u8 
**ret_data, u16 size)
        if (!pf)
                return -EINVAL;
 
-       data = devm_kzalloc(ice_pf_to_dev(pf), size, GFP_KERNEL);
+       data = kzalloc(size, GFP_KERNEL);
        if (!data)
                return -ENOMEM;
 
@@ -944,11 +944,9 @@ static u64 ice_loopback_test(struct net_device *netdev)
        int num_frames, valid_frames;
        struct ice_tx_ring *tx_ring;
        struct ice_rx_ring *rx_ring;
-       struct device *dev;
-       u8 *tx_frame;
+       u8 *tx_frame __free(kfree);
        int i;
 
-       dev = ice_pf_to_dev(pf);
        netdev_info(netdev, "loopback test\n");
 
        test_vsi = ice_lb_vsi_setup(pf, pf->hw.port_info);
@@ -993,7 +991,7 @@ static u64 ice_loopback_test(struct net_device *netdev)
        for (i = 0; i < num_frames; i++) {
                if (ice_diag_send(tx_ring, tx_frame, ICE_LB_FRAME_SIZE)) {
                        ret = 8;
-                       goto lbtest_free_frame;
+                       goto remove_mac_filters;
                }
        }
 
@@ -1003,8 +1001,6 @@ static u64 ice_loopback_test(struct net_device *netdev)
        else if (valid_frames != num_frames)
                ret = 10;
 
-lbtest_free_frame:
-       devm_kfree(dev, tx_frame);
 remove_mac_filters:
        if (ice_fltr_remove_mac(test_vsi, broadcast, ICE_FWD_TO_VSI))
                netdev_err(netdev, "Could not remove MAC filter for the test 
VSI\n");
-- 
2.34.1

Reply via email to