soc: tegra: fix coverity errors
Dara Ramesh [Tue, 5 Mar 2013 10:44:53 +0000 (15:44 +0530)]
fix memory cleanup and array comparison with null.
Coverity id : 22509
Coverity id : 22512

Bug 1046331

Change-Id: Ib27b0814c2744024f36fa3f3f510927eceb490a1
Signed-off-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-on: http://git-master/r/209444
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Scott Peterson <speterson@nvidia.com>

sound/soc/tegra/tegra_aic326x.c
sound/soc/tegra/tegra_cs42l73.c

index e2b4452..f05a78a 100644 (file)
@@ -1524,7 +1524,7 @@ static int tegra_aic326x_driver_probe(struct platform_device *pdev)
        }
 #endif
 
-       if (pdata->edp_states == NULL)
+       if (!pdata->edp_support)
                return 0;
 
        machine->spk_edp_client = devm_kzalloc(&pdev->dev,
@@ -1545,6 +1545,8 @@ static int tegra_aic326x_driver_probe(struct platform_device *pdev)
 
        battery_manager = edp_get_manager("battery");
        if (!battery_manager) {
+               devm_kfree(&pdev->dev, machine->spk_edp_client);
+               machine->spk_edp_client = NULL;
                dev_err(&pdev->dev, "unable to get edp manager\n");
        } else {
                /* register speaker edp client */
index 515b9d4..eb0ce53 100644 (file)
@@ -1432,7 +1432,7 @@ static __devinit int tegra_cs42l73_driver_probe(struct platform_device *pdev)
                goto err_unregister_card;
        }
 
-       if (pdata->edp_states == NULL)
+       if (!pdata->edp_support)
                return 0;
 
        machine->spk_edp_client = devm_kzalloc(&pdev->dev,
@@ -1453,6 +1453,8 @@ static __devinit int tegra_cs42l73_driver_probe(struct platform_device *pdev)
 
        battery_manager = edp_get_manager("battery");
        if (!battery_manager) {
+               devm_kfree(&pdev->dev, machine->spk_edp_client);
+               machine->spk_edp_client = NULL;
                dev_err(&pdev->dev, "unable to get edp manager\n");
        } else {
                /* register speaker edp client */