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

mfd: Fix da903x_add_subdevs error path

This patch fixes da903x_add_subdevs error path:
1. return -ENOMEM if platform_device_alloc() fail.
2. call platform_device_put() if platform_device_add() fail.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Eric Miao <eric.y.miao@gmail.com>
Acked-by: Mike Rapoport <mike@compulab.co.il>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Axel Lin and committed by
Samuel Ortiz
b59cedef 2c36af7b

+7 -1
+7 -1
drivers/mfd/da903x.c
··· 470 470 subdev = &pdata->subdevs[i]; 471 471 472 472 pdev = platform_device_alloc(subdev->name, subdev->id); 473 + if (!pdev) { 474 + ret = -ENOMEM; 475 + goto failed; 476 + } 473 477 474 478 pdev->dev.parent = chip->dev; 475 479 pdev->dev.platform_data = subdev->platform_data; 476 480 477 481 ret = platform_device_add(pdev); 478 - if (ret) 482 + if (ret) { 483 + platform_device_put(pdev); 479 484 goto failed; 485 + } 480 486 } 481 487 return 0; 482 488