It's safe to call regulator_unregister with NULL. In additional, having NULL check in the for loop is wrong because the for loop exits if pm800_data->regulators[i] is NULL. So we have have some regulators remains registered.
Signed-off-by: Axel Lin <axel....@ingics.com> --- drivers/regulator/88pm800.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c index afa3762..1fc1899 100644 --- a/drivers/regulator/88pm800.c +++ b/drivers/regulator/88pm800.c @@ -405,7 +405,7 @@ static int pm800_regulator_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to register %s\n", info->desc.name); - while (--i >= 0 && pm800_data->regulators[i]) + while (--i >= 0) regulator_unregister(pm800_data->regulators[i]); return ret; @@ -420,7 +420,7 @@ static int pm800_regulator_remove(struct platform_device *pdev) struct pm800_regulators *pm800_data = platform_get_drvdata(pdev); int i; - for (i = 0; pm800_data->regulators[i] && i < PM800_ID_RG_MAX; i++) + for (i = 0; i < PM800_ID_RG_MAX; i++) regulator_unregister(pm800_data->regulators[i]); return 0; -- 1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/