mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
mfd: ab8500: Fix child device leaks on probe failure
ab8500_probe() registers MFD child devices before completing the remaining device initialization. If a later MFD registration or sysfs group creation fails, previously registered child devices are not removed. Use devm_mfd_add_devices() so registered MFD child devices are removed when probe fails. The issue was identified by a static analysis tool I developed and confirmed by manual review. Fixes:cca69b67b3("mfd: Export ab8500 chip id to sysfs") Fixes:9c717cf3fa("mfd: ab8500-core: Add device for new RTC version for AB8540 cut2") Cc: stable@vger.kernel.org Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com> Link: https://patch.msgid.link/20260924144355.1604369-1-lgs201920130244@gmail.com Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
198f3bfc66
commit
5bf2ae8b13
|
|
@ -1194,39 +1194,41 @@ static int ab8500_probe(struct platform_device *pdev)
|
|||
return ret;
|
||||
|
||||
if (is_ab9540(ab8500))
|
||||
ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs,
|
||||
ARRAY_SIZE(ab9540_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
ret = devm_mfd_add_devices(ab8500->dev, 0, ab9540_devs,
|
||||
ARRAY_SIZE(ab9540_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
else if (is_ab8540(ab8500)) {
|
||||
ret = mfd_add_devices(ab8500->dev, 0, ab8540_devs,
|
||||
ARRAY_SIZE(ab8540_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
ret = devm_mfd_add_devices(ab8500->dev, 0, ab8540_devs,
|
||||
ARRAY_SIZE(ab8540_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (is_ab8540_1p2_or_earlier(ab8500))
|
||||
ret = mfd_add_devices(ab8500->dev, 0, ab8540_cut1_devs,
|
||||
ARRAY_SIZE(ab8540_cut1_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
ret = devm_mfd_add_devices(ab8500->dev, 0,
|
||||
ab8540_cut1_devs,
|
||||
ARRAY_SIZE(ab8540_cut1_devs),
|
||||
NULL, 0, ab8500->domain);
|
||||
else /* ab8540 >= cut2 */
|
||||
ret = mfd_add_devices(ab8500->dev, 0, ab8540_cut2_devs,
|
||||
ARRAY_SIZE(ab8540_cut2_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
ret = devm_mfd_add_devices(ab8500->dev, 0,
|
||||
ab8540_cut2_devs,
|
||||
ARRAY_SIZE(ab8540_cut2_devs),
|
||||
NULL, 0, ab8500->domain);
|
||||
} else if (is_ab8505(ab8500))
|
||||
ret = mfd_add_devices(ab8500->dev, 0, ab8505_devs,
|
||||
ARRAY_SIZE(ab8505_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
ret = devm_mfd_add_devices(ab8500->dev, 0, ab8505_devs,
|
||||
ARRAY_SIZE(ab8505_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
else
|
||||
ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs,
|
||||
ARRAY_SIZE(ab8500_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
ret = devm_mfd_add_devices(ab8500->dev, 0, ab8500_devs,
|
||||
ARRAY_SIZE(ab8500_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Add battery management devices */
|
||||
ret = mfd_add_devices(ab8500->dev, 0, ab8500_bm_devs,
|
||||
ARRAY_SIZE(ab8500_bm_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
ret = devm_mfd_add_devices(ab8500->dev, 0, ab8500_bm_devs,
|
||||
ARRAY_SIZE(ab8500_bm_devs), NULL,
|
||||
0, ab8500->domain);
|
||||
if (ret)
|
||||
dev_err(ab8500->dev, "error adding bm devices\n");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user