media: camss: Fix OF node usage
authorTodor Tomov <todor.tomov@linaro.org>
Wed, 25 Jul 2018 16:38:15 +0000 (12:38 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 2 Aug 2018 10:10:38 +0000 (06:10 -0400)
of_graph_get_next_endpoint increases the refcount of the returned
node and decreases the refcount of the passed node. Take this into
account and use of_node_put properly.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/platform/qcom/camss/camss.c

index 45285eb6842cf924fcb0c73e6229bd19aabeca90..abf6184891874a899d7e98ace5b200a67fcaf2b3 100644 (file)
@@ -296,6 +296,7 @@ static int camss_of_parse_ports(struct device *dev,
                if (of_device_is_available(node))
                        notifier->num_subdevs++;
 
+       of_node_put(node);
        size = sizeof(*notifier->subdevs) * notifier->num_subdevs;
        notifier->subdevs = devm_kzalloc(dev, size, GFP_KERNEL);
        if (!notifier->subdevs) {
@@ -326,16 +327,16 @@ static int camss_of_parse_ports(struct device *dev,
                }
 
                remote = of_graph_get_remote_port_parent(node);
-               of_node_put(node);
-
                if (!remote) {
                        dev_err(dev, "Cannot get remote parent\n");
+                       of_node_put(node);
                        return -EINVAL;
                }
 
                csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
                csd->asd.match.fwnode = of_fwnode_handle(remote);
        }
+       of_node_put(node);
 
        return notifier->num_subdevs;
 }