Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC/ie31200: Fix error handling in ie31200_register_mci

ie31200_register_mci() calls device_initialize() for priv->dev
unconditionally. However, in the error path, put_device() is not
called, leading to an imbalance. Similarly, in the unload path,
put_device() is missing.

Although edac_mc_free() eventually frees the memory, it does not
release the device initialized by device_initialize(). For code
readability and proper pairing of device_initialize()/put_device(),
add put_device() calls in both error and unload paths.

Found by code review.

Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Link: https://patch.msgid.link/20251106084735.35017-1-make24@iscas.ac.cn

authored by

Ma Ke and committed by
Tony Luck
f18e71cd 8616025a

+2
+2
drivers/edac/ie31200_edac.c
··· 526 526 ie31200_pvt.priv[mc] = priv; 527 527 return 0; 528 528 fail_unmap: 529 + put_device(&priv->dev); 529 530 iounmap(window); 530 531 fail_free: 531 532 edac_mc_free(mci); ··· 599 598 mci = priv->mci; 600 599 edac_mc_del_mc(mci->pdev); 601 600 iounmap(priv->window); 601 + put_device(&priv->dev); 602 602 edac_mc_free(mci); 603 603 } 604 604 }