Commit 4d6ec3a7 authored by Haotian Zhang's avatar Haotian Zhang Committed by Jakub Kicinski
Browse files

net: wan: framer: pef2256: Switch to devm_mfd_add_devices()



The driver calls mfd_add_devices() but fails to call mfd_remove_devices()
in error paths after successful MFD device registration and in the remove
function. This leads to resource leaks where MFD child devices are not
properly unregistered.

Replace mfd_add_devices with devm_mfd_add_devices to automatically
manage the device resources.

Fixes: c96e976d ("net: wan: framer: Add support for the Lantiq PEF2256 framer")
Suggested-by: default avatarHerve Codina <herve.codina@bootlin.com>
Signed-off-by: default avatarHaotian Zhang <vulab@iscas.ac.cn>
Acked-by: default avatarHerve Codina <herve.codina@bootlin.com>
Link: https://patch.msgid.link/20251105034716.662-1-vulab@iscas.ac.cn


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a04ea57a
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -648,7 +648,8 @@ static int pef2256_add_audio_devices(struct pef2256 *pef2256)
		audio_devs[i].id = i;
	}

	ret = mfd_add_devices(pef2256->dev, 0, audio_devs, count, NULL, 0, NULL);
	ret = devm_mfd_add_devices(pef2256->dev, 0, audio_devs, count,
				   NULL, 0, NULL);
	kfree(audio_devs);
	return ret;
}
@@ -822,7 +823,7 @@ static int pef2256_probe(struct platform_device *pdev)

	platform_set_drvdata(pdev, pef2256);

	ret = mfd_add_devices(pef2256->dev, 0, pef2256_devs,
	ret = devm_mfd_add_devices(pef2256->dev, 0, pef2256_devs,
				   ARRAY_SIZE(pef2256_devs), NULL, 0, NULL);
	if (ret) {
		dev_err(pef2256->dev, "add devices failed (%d)\n", ret);