[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250624142641.7010-3-emil.s.tantilov@intel.com>
Date: Tue, 24 Jun 2025 07:26:41 -0700
From: Emil Tantilov <emil.s.tantilov@...el.com>
To: intel-wired-lan@...ts.osuosl.org
Cc: netdev@...r.kernel.org,
Aleksandr.Loktionov@...el.com,
przemyslaw.kitszel@...el.com,
david.m.ertman@...el.com,
anthony.l.nguyen@...el.com,
michal.swiatkowski@...ux.intel.com,
andrew+netdev@...n.ch,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com
Subject: [PATCH iwl-net 2/2] ice: fix possible leak in ice_plug_aux_dev() error path
Fix a memory leak in the error path where kfree(iadev) was not called
following an error in auxiliary_device_add().
Fixes: f9f5301e7e2d ("ice: Register auxiliary device to provide RDMA")
Signed-off-by: Emil Tantilov <emil.s.tantilov@...el.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@...el.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@...el.com>
---
drivers/net/ethernet/intel/ice/ice_idc.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_idc.c b/drivers/net/ethernet/intel/ice/ice_idc.c
index 420d45c2558b..8c4a3dc22a7c 100644
--- a/drivers/net/ethernet/intel/ice/ice_idc.c
+++ b/drivers/net/ethernet/intel/ice/ice_idc.c
@@ -322,16 +322,12 @@ int ice_plug_aux_dev(struct ice_pf *pf)
"roce" : "iwarp";
ret = auxiliary_device_init(adev);
- if (ret) {
- kfree(iadev);
- return ret;
- }
+ if (ret)
+ goto free_iadev;
ret = auxiliary_device_add(adev);
- if (ret) {
- auxiliary_device_uninit(adev);
- return ret;
- }
+ if (ret)
+ goto aux_dev_uninit;
mutex_lock(&pf->adev_mutex);
cdev->adev = adev;
@@ -339,6 +335,13 @@ int ice_plug_aux_dev(struct ice_pf *pf)
set_bit(ICE_FLAG_AUX_DEV_CREATED, pf->flags);
return 0;
+
+aux_dev_uninit:
+ auxiliary_device_uninit(adev);
+free_iadev:
+ kfree(iadev);
+
+ return ret;
}
/* ice_unplug_aux_dev - unregister and free AUX device
--
2.37.3
Powered by blists - more mailing lists