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

EDAC/al_mc: Make use of the helper function devm_add_action_or_reset()

The helper function devm_add_action_or_reset() will internally call
devm_add_action(), and if devm_add_action() fails then it will
execute the action mentioned and return the error code. So use
devm_add_action_or_reset() instead of devm_add_action() to simplify the
error handling, reduce the code.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Talel Shenhar <talel@amazon.com>
Link: https://lkml.kernel.org/r/20210922125924.321-1-caihuoqing@baidu.com

authored by

Cai Huoqing and committed by
Borislav Petkov
470b5256 fca61165

+4 -8
+4 -8
drivers/edac/al_mc_edac.c
··· 238 238 if (!mci) 239 239 return -ENOMEM; 240 240 241 - ret = devm_add_action(&pdev->dev, devm_al_mc_edac_free, mci); 242 - if (ret) { 243 - edac_mc_free(mci); 241 + ret = devm_add_action_or_reset(&pdev->dev, devm_al_mc_edac_free, mci); 242 + if (ret) 244 243 return ret; 245 - } 246 244 247 245 platform_set_drvdata(pdev, mci); 248 246 al_mc = mci->pvt_info; ··· 291 293 return ret; 292 294 } 293 295 294 - ret = devm_add_action(&pdev->dev, devm_al_mc_edac_del, &pdev->dev); 295 - if (ret) { 296 - edac_mc_del_mc(&pdev->dev); 296 + ret = devm_add_action_or_reset(&pdev->dev, devm_al_mc_edac_del, &pdev->dev); 297 + if (ret) 297 298 return ret; 298 - } 299 299 300 300 if (al_mc->irq_ue > 0) { 301 301 ret = devm_request_irq(&pdev->dev,