Skip to content

Commit 467d3a9

Browse files
etantilovanguy11
authored andcommitted
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: f9f5301 ("ice: Register auxiliary device to provide RDMA") Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
1 parent 91964be commit 467d3a9

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

drivers/net/ethernet/intel/ice/ice_idc.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,23 +322,26 @@ int ice_plug_aux_dev(struct ice_pf *pf)
322322
"roce" : "iwarp";
323323

324324
ret = auxiliary_device_init(adev);
325-
if (ret) {
326-
kfree(iadev);
327-
return ret;
328-
}
325+
if (ret)
326+
goto free_iadev;
329327

330328
ret = auxiliary_device_add(adev);
331-
if (ret) {
332-
auxiliary_device_uninit(adev);
333-
return ret;
334-
}
329+
if (ret)
330+
goto aux_dev_uninit;
335331

336332
mutex_lock(&pf->adev_mutex);
337333
cdev->adev = adev;
338334
mutex_unlock(&pf->adev_mutex);
339335
set_bit(ICE_FLAG_AUX_DEV_CREATED, pf->flags);
340336

341337
return 0;
338+
339+
aux_dev_uninit:
340+
auxiliary_device_uninit(adev);
341+
free_iadev:
342+
kfree(iadev);
343+
344+
return ret;
342345
}
343346

344347
/* ice_unplug_aux_dev - unregister and free AUX device

0 commit comments

Comments
 (0)