[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 3/3] Free allocated resource on error



Also do not set mark device as SMMU protected when there are no more
SMMU resources left

Coverity-ID: 1381862
Signed-off-by: Artem Mygaiev <artem_mygaiev@xxxxxxxx>
---
 xen/drivers/passthrough/arm/smmu.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/arm/smmu.c 
b/xen/drivers/passthrough/arm/smmu.c
index f151b9f5b5..cf42335eed 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -804,9 +804,6 @@ static int register_smmu_master(struct arm_smmu_device 
*smmu,
        master->of_node                 = masterspec->np;
        master->cfg.num_streamids       = masterspec->args_count;
 
-       /* Xen: Let Xen know that the device is protected by an SMMU */
-       dt_device_set_protected(masterspec->np);
-
        for (i = 0; i < master->cfg.num_streamids; ++i) {
                u16 streamid = masterspec->args[i];
 
@@ -815,10 +812,15 @@ static int register_smmu_master(struct arm_smmu_device 
*smmu,
                        dev_err(dev,
                                "stream ID for master device %s greater than 
maximum allowed (%d)\n",
                                masterspec->np->name, smmu->num_mapping_groups);
+                       devm_free(master);
                        return -ERANGE;
                }
                master->cfg.streamids[i] = streamid;
        }
+
+        /* Xen: Let Xen know that the device is protected by an SMMU */
+        dt_device_set_protected(masterspec->np);
+
        return insert_smmu_master(smmu, master);
 }
 
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.