nfit: use devm_add_action_or_reset()
authorSajjan, Vikas C <vikas.cha.sajjan@hpe.com>
Mon, 4 Jul 2016 04:32:51 +0000 (10:02 +0530)
committerDan Williams <dan.j.williams@intel.com>
Wed, 6 Jul 2016 22:12:41 +0000 (15:12 -0700)
If devm_add_action() fails, we are explicitly calling the cleanup to free
the resources allocated. Lets use the helper devm_add_action_or_reset()
and return directly in case of error, since the cleanup function
has been already called by the helper if there was any error.

Signed-off-by: Vikas C Sajjan <vikas.cha.sajjan@hpe.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Lee, Chun-Yi <jlee@suse.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/acpi/nfit.c

index da14c89f46679b441ec3a18e6e014074a7e21825..3e54157f02cc8dc3ec520ff4c57dcf32d8fdb345 100644 (file)
@@ -1920,11 +1920,11 @@ static int acpi_nfit_insert_resource(struct acpi_nfit_desc *acpi_desc,
        if (ret)
                return ret;
 
-       ret = devm_add_action(acpi_desc->dev, acpi_nfit_remove_resource, res);
-       if (ret) {
-               remove_resource(res);
+       ret = devm_add_action_or_reset(acpi_desc->dev,
+                                       acpi_nfit_remove_resource,
+                                       res);
+       if (ret)
                return ret;
-       }
 
        return 0;
 }
This page took 0.027981 seconds and 5 git commands to generate.